[issue8389] Incomprehensible import error

Brett Cannon report at bugs.python.org
Wed Apr 14 22:15:10 CEST 2010


Brett Cannon <brett at python.org> added the comment:

First off, the 'as' clause is not influencing anything; simply try to assign ``t = a.b.t`` and you still get the error.

Second, you are trying to reference a.b in a.b.c through your a.b.t import before a.b has finished importing. This is causing the import system to not have a chance to bind the b module to a.b before you try to reference it.

The reason ``from a.b import t`` works is the 'from' clause is handled after all imports resolve as a separate step, so everything settles, gets imported, and then Python tries to get a.b.t long after a.b if finished.

In other words it's a funky import cycle which you break with ``from a.b import t``. Nothing we can do to change it.

----------
resolution:  -> invalid
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8389>
_______________________________________


More information about the Python-bugs-list mailing list