This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author bronger
Recipients bronger, dcjim, jhylton, loewis, ncoghlan, tim.peters
Date 2008-04-11.06:32:41
SpamBayes Score 0.04854628
Marked as misclassified No
Message-id <1207895563.13.0.965783290686.issue992389@psf.upfronthosting.co.za>
In-reply-to
Content
I have a very similar issue (maybe the same?) at the moment.

Assume the follwing package structure:

main.py
package/
    __init__.py   [empty]
    moduleX.py
    moduleY.py

main.py says:

    from package import moduleX

moduleX.py says:

    from . import moduleY

and moduleY.py says:

    from . import moduleX

However, this doesn't work:

    bronger@wilson:~/temp/packages-test$ python main.py
    Traceback (most recent call last):
      File "main.py", line 1, in <module>
        from package import moduleX
      File "/home/bronger/temp/packages-test/package/moduleX.py", line
1, in <module>
        from . import moduleY
      File "/home/bronger/temp/packages-test/package/moduleY.py", line
1, in <module>
        from . import moduleX
    ImportError: cannot import name moduleX

If I turn the relative imports to absolutes ones, it works.  But I'd
prefer the relative notation for intra-package imports.  That's their
purpose after all.

If you split a large module into chunks, cyclic imports are hardly
avoidable (and there's nothing bad about it; it worked fine before PEP 328).

Note that "import absolute.path.to.module as short" doesn't work either.
 So currently, in presence of cyclic imports in a package, the only
remedy is to use the full absolute paths everywhere in the source code,
which is really awkward in my opinion.
History
Date User Action Args
2008-04-11 06:32:43brongersetspambayes_score: 0.0485463 -> 0.04854628
recipients: + bronger, tim.peters, loewis, jhylton, dcjim, ncoghlan
2008-04-11 06:32:43brongersetspambayes_score: 0.0485463 -> 0.0485463
messageid: <1207895563.13.0.965783290686.issue992389@psf.upfronthosting.co.za>
2008-04-11 06:32:42brongerlinkissue992389 messages
2008-04-11 06:32:41brongercreate