[Python-Dev] PythonCore\CurrentVersion

Tim Peters tim.peters at gmail.com
Tue Oct 11 18:08:42 CEST 2005

>> Well, that's in interactive mode, and I see sys.path[0] == "" on both
>> Windows and Linux then.  I don't see "" in sys.path on either box in
>> batch mode, although I do see the absolutized path to the current
>> directory in sys.path in batch mode on Windows but not on Linux -- but
>> Mark Hammond says he doesn't see (any form of) the current directory
>> in sys.path in batch mode on Windows.
>> It's a bit confusing ;-)

> How did you test batch mode?

I gave full code (it's brief) and screen-scrapes from Windows and
Linux yesterday:


By batch mode, I meant invoking

    path_to_python   path_to_python_script.py

from a shell prompt.

> All:
> sys.path[0] is *not* defined to be the current directory.
> It is defined to be the directory of the script that was used to
> invoke python (sys.argv[0], typically).

In my runs, sys.argv[0] was the path to the Python executable, not to
the script being run.  The directory of the script being run was
nevertheless in sys.path[0] on both Windows and Linux.  On Windows,
but not on Linux, the _current_ directory (the directory I happened to
be in at the time I invoked Python) was also on sys.path; Mark Hammond
said it was not when he tried, but he didn't show exactly what he did
so I'm not sure what he saw.

> If there is no script, or it is being read from stdin, the default is ''.

I believe everyone sees that.

More information about the Python-Dev mailing list