"Steven D'Aprano" <steve+comp.lang.pyt...@pearwood.info> wrote in message news:4d6a56aa$0$29972$c3e8da3$54964...@news.astraweb.com...
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.



Thanks, Steven.

I confirm that 'import pkg.mod* works. Unfortunately I am using sub-packages as well, which means that to refer to an object in the sub-package I need to use w.x.y.z every time, which gets to be a lot of typing! I will stick to my hack of putting the package name in sys.path for now, unless someone comes up with a better idea.

Frank


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to