[Python-Dev] PythonCore\CurrentVersion

Tim Peters tim.peters at gmail.com
Tue Oct 11 21:09:02 CEST 2005

> I tried your experiment but added 'print sys.argv[0]' and didn't see
> that. sys.argv[0] is the path to the script.

My mistake!  You're right, sys.argv[0] is the path to the script for me too.

>> 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.

> I see what you see.  The first entry is the script's directory, the
> 2nd is a nonexistent zip file, the 3rd is the current directory, then
> the rest is standard library stuff.

So why doesn't Mark see that?  I'll ask him ;-)

> I suppose PC/getpathp.c puts it there, per your post quoted above?

I don't think it does (although I understand why it's sane to believe
that it must).  Curiously, I do _not_ see the current directory on
sys.path on Windows if I run from current CVS HEAD.  I do see it
running Pythons 2.2.3, 2.3.5 and 2.4.2.  PC/getpathp.c doesn't appear
to have changed in a relevant way.


import sys
from pprint import pprint
print sys.version_info

C:\>\code\python\PCbuild\python.exe code\blor.py  # C:\ not in sys.path
(2, 5, 0, 'alpha', 0)

C:\>\python24\python.exe code\blor.py  # C:\ in sys.path
(2, 4, 2, 'final', 0)

More information about the Python-Dev mailing list