resolving module name conflicts.

Eric Snow ericsnowcurrently at gmail.com
Fri Nov 11 16:51:12 EST 2011


On Fri, Nov 11, 2011 at 2:34 PM, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> The problem is that the empty string is still added to the from of
> sys.path.  I'm going to have to find out more about that one.

Okay, don't know how I missed it but the docs for sys.path[1] spell it out:

    "As initialized upon program startup, the first item of this list,
path[0], is the directory containing the script that was used to
invoke the Python interpreter. If the script directory is not
available (e.g. if the interpreter is invoked interactively or if the
script is read from standard input), path[0] is the empty string,
which directs Python to search modules in the current directory
first."

So if you run a module as a script, that empty string will be added to
sys.path and all imports will first check the directory you were in
when you ran Python...

-eric


[1] http://docs.python.org/library/sys.html#sys.path



More information about the Python-list mailing list