circular imports

qhfgva at gmail.com qhfgva at gmail.com
Fri May 20 10:38:18 EDT 2005


I'm working with a large code base that I'm slowly trying to fix
"unpythonic" features of.

One feature I'm trying to fix is the use of:

# how things are now
sys.path.append('/general/path/aaa/bbb') # lots of lines like this to
specific dirs
import foo

Insead I'd rather have PYTHONPATH already include '/general/path/'
and then just use:

# how I'd like them to be
from aaa.bbb import foo

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.

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

thanks,

dustin




More information about the Python-list mailing list