[Python-Dev] New relative import issue

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Sep 19 05:46:59 CEST 2006

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

> there
> is no clean way from a test module 'foo.bar.test.test_hello' 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.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list