saved sys.path

Peter Hansen peter at engcorp.com
Tue Nov 2 08:41:47 EST 2004


Eric S. Johansson wrote:
> one of the things I've been bothered with using Python for larger 
> applications is path manipulation.  For example, how does one create the 
> search path necessary to find your own modules if you do not wish 
> pollute site-packages with your private code.
> 
> the path file looks like this might be a good solution in preference to 
> modifying sys.path in your code.  Are there any scope or limitation 
> rules for this path modifier?  Can this modification be made specific to 
> an application or is the new path visible to the entire world (which 
> reintroduces the namespace pollution problem).

Most questions relating to this which haven't already been answered
by Alex can be answered by a perusal of the site.py source.  It
makes good readin'...

Note that between PYTHONPATH and .pth files, possibly the addition
of a little sitecustomize.py file (see again site.py), and the
ability to modify sys.path in the __main__ module of the app as
Alex suggests, you can do pretty much anything you think is a good
thing to do.

-Peter



More information about the Python-list mailing list