[Python-Dev] relative import circular problem

Kristján Valur Jónsson kristjan at ccpgames.com
Fri Apr 5 13:18:08 CEST 2013


+1. I was thinking along the same lines.
Allowing relative imports in "import module [as X]" statements.
If 'module' consists of pure dots, then "as X" is required.
Otherwise, if "as X" is not present, strip the leading dot(s) when assigning the local name.
K

> -----Original Message-----
> From: Python-Dev [mailto:python-dev-
> bounces+kristjan=ccpgames.com at python.org] On Behalf Of Richard
> Oudkerk
> Sent: 4. apríl 2013 16:26
> To: python-dev at python.org
> Subject: Re: [Python-Dev] relative import circular problem
> 
>
 
> How about having a form of relative import which only works for
> submodules.  For instance, instead of
> 
>      from . import moduleX
> 
> write
> 
>      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