[英]python: What's the rationale behind not allowing * in relative imports?
What's the rationale behind not allowing * in relative imports?在相对进口中不允许 * 的原因是什么? eg例如
from ..new_tool import *
or doing a relative import directly:或直接进行相对导入:
import ..new_tool
The reason the latter is prohibited is that ..new_tool
is not usable in an expression (PEP 328) :禁止后者的原因是..new_tool
不能在表达式中使用(PEP 328) :
The reason
import.foo
is prohibited is because after禁止import.foo
的原因是因为在import XXX.YYY.ZZZ
then
XXX.YYY.ZZZ
is usable in an expression.那么XXX.YYY.ZZZ
可以在表达式中使用。 But但.moduleY
is not usable in an expression.不能在表达式中使用。
Since *
-imports should only ever be a quick hack while in development, I suspect the functionality for relative *
-imports was left out because it's not necessary.由于*
-imports 在开发过程中应该只是一个快速破解,我怀疑相对*
-imports 的功能被遗漏了,因为它不是必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.