[Python-Dev] relative import circular problem

Richard Oudkerk shibturn at gmail.com
Thu Apr 4 18:26:04 CEST 2013

On 04/04/2013 4:17pm, Guido van Rossum wrote:
> I don't really see what we could change to avoid breaking code in any
> particular case -- the burden is up to the library to do it right. I
> don't see a reason to forbid any of this either.

How about having a form of relative import which only works for 
submodules.  For instance, instead of

     from . import moduleX


     import .moduleX

which is currently a SyntaxError.  I think this could be implemented as

     moduleX = importlib.import_module('.moduleX', __package__)


More information about the Python-Dev mailing list