[Python-Dev] PEP 273: Import Modules from Zip Archives
Tim Peters
tim.one@home.com
Mon, 29 Oct 2001 13:14:56 -0500
[James C. Ahlstrom]
> The zip archive name is always inserted as the second item
> in sys.path. The first always seems to be ''.
Running p.py:
import sys
print `sys.path[0]`
on Windows gives:
C:\Code\python\PCbuild>python p.py
''
C:\Code\python\PCbuild>cd ..
C:\Code\python>pcbuild\python pcbuild\p.py
'pcbuild'
C:\Code\python>pcbuild\python \code\python\pcbuild\p.py
'\\code\\python\\pcbuild'
C:\Code\python>cd pcbuild
C:\Code\python\PCbuild>python .\p.py
'.'
C:\Code\python\PCbuild>move p.py ..\lib
C:\CODE\PYTHON\PCBUILD\p.py => C:\CODE\PYTHON\lib\p.py [ok]
C:\Code\python\PCbuild>python ..\lib\p.py
'..\\lib'
C:\Code\python\PCbuild>
That is, the first entry is the path (relative or absolute!) to the
directory in which the script being executed lives.