[英]How to combine two overlapping import statements into one
Can I write the following two lines of code in one?我可以将以下两行代码合二为一吗?
from file import *
from file import foo as class_01
Yes, but doing that imposes poorly readable code as it introduces unknown names to the interpreter.是的,但是这样做会导致代码可读性差,因为它向解释器引入了未知名称。
Instead, consider importing all needed names相反,请考虑导入所有需要的名称
from file import bar, foo as class_01
是的,你可以,但建议在模块中导入特定的类示例:
from shutil import make_archive as m_a,copy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.