circular imports

"Martin v. Löwis" martin at v.loewis.de
Fri May 20 12:20:09 EDT 2005


qhfgva at gmail.com wrote:
> So I thought I'd just add the necessary __init__.py files and then
> things would just work.  Unfortunately trying this exposed a large
> number of circular imports which now cause the files to fail to load.

You didn't describe you you created the necessary __init__.py files.
If they are not empty, there is a good chance that you made some
error in creating these files.

What is the error that you get with the circular imports?

> Any ideas why the sys.path.append method has no problem with circular
> imports whereas doing thing the "right way" chokes.

One reason is that there could be duplicate module names, e.g. overlaps
with the standard library. When you fully-qualified the modules, you
actually changed the program, which would now import the user-provided
modules instead of the predefined ones.

Regards,
Martin



More information about the Python-list mailing list