[Python-Dev] relative import circular problem

Barry Warsaw barry at python.org
Tue Apr 2 00:15:59 CEST 2013

On Apr 01, 2013, at 08:20 PM, Kristján Valur Jónsson wrote:

>The relative import syntax
> (from foo import bar) is a getattr type of lookup (i.e. import foo, then get
> attr from it).
>This is in contrast with absolute import
>  import foo.bar  (get the module foo.bar from sys.modules or import it)
>  bar = foo.bar

I always thought of both syntaxes as absolute imports because they both name
the full dotted path to the module you want.  This contrasts with true PEP
328 relative imports such as:

    from ..foo import bar

>the latter works with partially initialized modules, but not the former,
>rendering two sibling modules unable to import each other using the relative
>as far as I know, relative imports are only supported using the former
>(import from) syntax.  Are there any plans to alleviate this by allowing
>proper relative imports?  After all, relative imports and packages go hand in

I personally dislike PEP 328 relative imports, since they seem fragile, but
that's a different discussion.


More information about the Python-Dev mailing list