2.4->2.5 current directory change?

Chris Mellon arkanes at gmail.com
Mon Feb 26 13:44:44 EST 2007


This appears to be a change in behavior from Python 2.4 to Python 2.5,
which I can't find documented anywhere. It may be windows only, or
related to Windows behavior.

In 2.4, the current directory (os.curdir) was on sys.path. In 2.5, it
appears to be the base directory of the running script. For example,
if you execute the file testme.py in your current working directory,
'' is on sys.path. If you execute c:\Python25\Scripts\testme.py, '' is
*not* on sys.path, and C:\Python25\Scripts is.

That means if you run a Python script located in another directory,
modules/etc in your current working directory will not be found. This
makes .py scripts in the PYTHONHOME\Scripts file moderately useless,
because they won't find anything in the current working directory.


I first noticed this because it breaks Trial, but I'm sure there are
other scripts affected by it. Is this desirable behavior? Is there
anything to work around it except by pushing os.curdir onto sys.path?



More information about the Python-list mailing list