Customizing the python search path depending on source directory

Peter Schwalm peter.schwalm at epost.de
Wed Apr 7 08:52:17 EDT 2004


Peter Hansen <peter at engcorp.com> wrote in message news:> >
.... 
> >     a) the source directory of the script is still not in sys.path
> 
> Are you sure?  Looking at site.py, it appears that the sitecustomize
> import is done next-to-last, just before sys.setdefaultencoding is
> deleted.  If you concluded this by examining sys.path manually at
> the point just as sitecustomize is imported, maybe you don't know
> that the '' entry in sys.path actually represents the source
> directory of the main script...

Thank you for your answer. But I'm afraid it's not the source
directory but the current working directory. You can see the
difference if you copy the passage

    "for ix1, p1 in enumerate(sys.path): print "%02.02d: %s" % (ix1,
p1)"

to a "normal script". If you start that "normal script" from a
directory other than the source directory, you can see that both
directories are included in sys.path. If you run this code inside
sitecustomize.py this is not the case.

Thank you
Peter



More information about the Python-list mailing list