Cycles between package imports
JohnRoth1 at jhrothjr.com
Sun Jun 18 14:25:14 CEST 2006
Martin Blais wrote:
> I'm a tad confused over a problem involving cycles between
[lengthy example snipped]
> I don't see why the reference to module a.alice could not be
> available via the "from" syntax, even if it is still incompletely
> initialized at the time of import.
> Can anyone shed some light onto this? Is there a rule for
> determining when a module becomes available to import from a
> package using the "from" syntax?
It's really easy to see if you trace out, in detail, the exact
order in which things happen and when each object is initialized and
shows up in the respective module's namespace.
The general rule is: don't do that. It doesn't work, and the
hoops you have to go through to force it to work are so
complex and bizzare that they're not worth it. Redesign
the modules so you don't have cyclic dependencies.
More information about the Python-list