[Python-Dev] PEP 328: import...as with relative import (original) (raw)

Guido van Rossum guido at python.org
Thu May 6 10:04:33 EDT 2004


There's been some discussion on c.l.py about whether the new relative import system should allow things like

import ..abc as def It seems the PEP currently disallows this, but nobody seems to be able to adequately explain why. Is there any technical reason it couldn't be done?

Because "import ..abc" is clearly nonsense, since after "import X" you should be able to the imported entity as "X" in your program, and "..abc" is not a valid expression.

This doesn't strictly apply to "import ..abc as xyz" ("def" was a poor choice for "X" :-), but it doesn't seem worth stretching the syntax when you can already do that using "from .. import abc as xyz".

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list