简体   繁体   English

在Python中“ from bar import foo”之后,“ [foo]”有什么特殊含义吗? (也许特定于python2)

[英]Is there some special meaning to `[foo]` right after `from bar import foo` in python? (perhaps python2 specific)

In particular, I am looking at this code: 特别是,我在看这段代码:

import sqlite3
from sqlite3 import IntegrityError
[IntegrityError]

and am wondering: Is there some special meaning to [IntegrityError] ? 并且想知道: [IntegrityError]是否有某些特殊含义?

IntegrityError is just a class defined in the sqlite3 package, and of course, my own interpretation is that [IntgrityError] would just be an expression that puts it in a list, yet there I have it in a piece of code that I am studying. IntegrityError只是sqlite3程序包中定义的一个类,当然,我自己的解释是[IntgrityError]只是一个将其放入列表的表达式,但在我正在研究的一段代码中就有了。 Could it be a typo? 可能是拼写错误吗? or am I missing some magic syntactic-sugar interpretation? 还是我缺少一些神奇的语法糖解释?

from sqlite3 import IntegrityError可以确保系统上已安装from sqlite3 import IntegrityError DB-API 2.0(PEP-249)版本,并且后续行[IntegrityError]抑制了linter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 python 中,“import foo.bar as bar”和“from foo import bar”有什么区别? - In python, what is the difference between 'import foo.bar as bar' and 'from foo import bar'? Python:将foo.bar导入为bar与从foo导入导入 - Python: import foo.bar as bar vs from foo import bar 如何从python中的方法从foo导入栏执行全局操作? - How to do a global from foo import bar from a method in python? 是否可以在python中执行“ from module.foo import * as bar”? - Is it possible to do “from module.foo import * as bar” in python? 在 Python 中理解 [foo for bar, foo in arr] - Understanding [foo for bar, foo in arr] in Python Django / Python:/ foo / bar中的ValueError - Django/Python: ValueError at /foo/bar 这是python反模式吗? '将foo.foo导入为foo'遮盖了foo包的其余部分 - Is this a python antipattern? 'import foo.foo as foo' shadows the rest of the foo package 如何在Python2.7中使用imp实现“从foo的bar导入栏为b”? - How can I do 'from foo import bar as b' with imp in Python2.7? 在python中,'foo ==(8或9)'或'foo == 8或foo == 9'更正确吗? - In python, is 'foo == (8 or 9)' or 'foo == 8 or foo == 9' more correct? 继承自 [foo] 的 tox.ini [foo:bar] 部分的 Python tox 文档? - Python tox documentation for tox.ini [foo:bar] section inheriting from [foo]?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM