[Python-Dev] New relative import issue (original) (raw)
Steve Holden steve at holdenweb.com
Tue Sep 19 14:40:45 CEST 2006
- Previous message: [Python-Dev] New relative import issue
- Next message: [Python-Dev] New relative import issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Greg Ewing wrote:
Armin Rigo wrote:
My (limited) understanding of the motivation for relative imports is that they are only here as a transitional feature. Fully-absolute imports are the official future. Guido does seem to have a dislike for relative imports, but I don't really understand why. The usefulness of being able to make a package self-contained and movable to another place in the package hierarchy without hacking it seems self-evident to me. What's happening in Py3k? Will relative imports still exist? there is no clean way from a test module 'foo.bar.test.testhello' to import 'foo.bar.hello': the top-level directory must first be inserted into sys.path magically. I've felt for a long time that problems like this wouldn't arise so much if there were a closer connection between the package hierarchy and the file system structure. There really shouldn't be any such thing as sys.path -- the view that any given module has of the package namespace should depend only on where it is, not on the history of how it came to be invoked. This does, of course, assume that you're importing modules from the filestore, which assumption is no longer valid in the presence of PEP 302 importers.
The current initialization code actually looks for os.py as a means of establishing path elements. This should really be better integrated with the PEP 302 mechanism: ideally Python should work on systems that don't rely on filestore for import (even though for the foreseeable future all systems will continue to do this).
regards Steve
Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden
- Previous message: [Python-Dev] New relative import issue
- Next message: [Python-Dev] New relative import issue
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]