[Python-Dev] Re: PEP 328 -- relative and multi-line import (original) (raw)

Chris McDonough chrism at plope.com
Mon Apr 12 00🔞29 EDT 2004


What is the rationale given for not allowing:

import .moduleY

as a relative import statement meaning "from the package containing the module running the import statement, import moduleY"? The PEP suggests that "relative imports will require listing specific names to import". I'm wondering what about "moduleY" in the above isn't specific?

FWIW, I read through much of the meanderings of the old threads but never saw a specific damnation-with-cause of this.

On Sun, 2004-04-11 at 13:23, Aahz wrote:

On Sun, Apr 11, 2004, Barry Warsaw wrote: > > This is one of the reasons I suggested early on that there be a way to > spell -- at the package level by the package developer -- "I'm using > absolute imports here". Without that spelling, the package would still > use the old semantics, however broken they are . > > E.g. if I could put in email/init.py something like: > > from future import iamabsolutelyresolvedaboutmyimports > > then I'd expect PEP 328 semantics in package email and all subpackages. > Older packages wouldn't have this declaration and would operate under > the old rules. (I still don't have any need for relative imports. ;)

Anyone else favor having the _future_ directive apply to the package and all its subpackages? (Currently it follows the standard rules of applying only to each module.) Note that this would make it impossible to do what some people want, where a package becomes another package's subpackage, if the new subpackage relies on relative imports under the old rules.



More information about the Python-Dev mailing list