有什么区别:
from file import (SomeMethod)
和:
from file import SomeMethod
为什么那里需要 ( )?
最佳答案
PEP 328 中描述了带括号的导入并在 Python 2.4 中添加。简而言之,<= Python 2.3 程序员被迫在多行导入中使用 \
进行行继续,即
from file import SomeMethod, \
AnotherMethod, \
ThirdMethod
这很烦人;因此决定允许使用括号进行分组,因为可以通过仅使用括号对表达式进行分组来避免在其他地方使用 \
行继续。
关于python - 进口风格的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24396025/