[Python-Dev] CWD in sys.path.

Finn Bock bckfnn@worldonline.dk
Fri, 15 Dec 2000 17:05:42 GMT


Hi,

I'm trying to understand the initialization of sys.path and especially
if CWD is supposed to be included in sys.path by default. (I understand
the purpose of sys.path[0], that is not the focus of my question).

My setup is Python2.0 on Win2000, no PYTHONHOME or PYTHONPATH envvars.

In this setup, an empty string exists as sys.path[1], but I'm unsure if
this is by careful design or some freak accident. The empty entry is
added because

  HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath 

does *not* have any subkey. There are a default value, but that value
appears to be ignored. If I add a subkey "foo":

  HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\2.0\PythonPath\foo 

with a default value of "d:\foo", the CWD is no longer in sys.path.

i:\java\jython.cvs\org\python\util>d:\Python20\python.exe  -S
Python 2.0 (#8, Oct 16 2000, 17:27:58) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', 'd:\\foo', 'D:\\PYTHON20\\DLLs', 'D:\\PYTHON20\\lib',
'D:\\PYTHON20\\lib\\plat-win', 'D:\\PYTHON20\\lib\\lib-tk',
'D:\\PYTHON20']
>>>

I noticed that some of the PYTHONPATH macros in PC/config.h includes the
'.', others does not.

So, to put it as a question (for jython): Should CWD be included in
sys.path? Are there some situation (like embedding) where CWD shouldn't
be in sys.path?

regards,
finn