简体   繁体   中英

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 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. 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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM