+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@python.org] On Behalf Of Richard Oudkerk Sent: 4. apríl 2013 16:26 To: python-dev@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__)
--