简体   繁体   中英

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

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