python: What's the rationale behind not allowing * in relative imports?
What's the rationale behind not allowing * in relative imports? e.g.
from ..new_tool import *
or doing a relative import directly:
import ..new开发者_Go百科_tool
The reason the latter is prohibited is that ..new_tool
is not usable in an expression (PEP 328):
The reason
import .foo
is prohibited is because afterimport XXX.YYY.ZZZ
then
XXX.YYY.ZZZ
is usable in an expression. 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.
精彩评论