Python default search paths

swapnil swapnil.st at gmail.com
Tue Oct 19 09:25:30 EDT 2010


Python allows adding user defined paths to the module search path by
setting PYTHONPATH environment variable. It also allows to alter the
location of standard python libraries using PYTHONHOME. But there is
no way to "only" have user defined paths to python's search paths
(sys.path)

This is useful for embedding applications where it might be desired
that only user-defined paths are searched for modules. But python
creates some default paths and adds it to sys.path.  Most of the times
it does not matter since PYTHONPATH paths are appended at the
beginning but this may sometimes result in unwanted behavior.

I think it would be a good idea to be able to say that you don't need
any default search paths. In this case if Python gives error if
PYTHONPATH is not set-  I think that would be reasonable. Since
otherwise sys.path would be empty!!

Please provide feedback for this feature request.



More information about the Python-list mailing list