[Python-Dev] New relative import issue

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Sep 22 02:40:03 CEST 2006


Guido van Rossum wrote:

> While I agree with your idea(l), I don't think that's what Greg meant.
> He clearly say "sys.path should not exist at all".

Refining that a bit, I don't think there should be
a *single* sys.path for the whole program -- more
like each module having its own sys.path. And, at
least in most cases, its contents should be set
up from static information that exists outside the
program, established when the module is installed.

One reason for this is the lack of any absolute
notion of a "program". What is a program on one
level can be part of a larger program on another
level. For example, a module with test code that
is run when it's invoked as a main script.
Sometimes it's a program of its own, other times
it's not. And it shouldn't *matter* whether it's
a program or not when it comes to being able to
find other modules that it needs to import. So
using a piece of program-wide shared state for
this seems wrong.

--
Greg


More information about the Python-Dev mailing list