Problem with python 3.2 and circular imports

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Feb 27 08:50:34 EST 2011


On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote:

> Assume the following structure -
> 
> main.py
> /pkg
>     __init__.py
>     mod1.py
>     mod2.py
> 
> main.py
>     from pkg import mod1
> 
> mod1.py
>     import mod2
> 
> mod2.py
>   import mod1


If you change the "import mod*" lines to "import pkg.mod*" it works for 
me in Python 3.1 and 3.2.

According to my understand of PEP 328, "from . import mod*" should work, 
but I agree with you that it doesn't.

If you get rid of the circular import, it does work. So I suspect a bug.



-- 
Steven



More information about the Python-list mailing list