PEP 271: Prefixing sys.path by command line option
frederic.giacometti at arakne.com
Tue Sep 18 03:43:46 CEST 2001
I'm pasting below the PEP 271 for python 2.2
(http://python.sourceforge.net/peps/pep-0271.html), for public debate.
The purpose of the PEP is the introduction of new command line option to
python (-P), whose role would be similar to java's -classpath option:
providing the ability to explicitly set the PYTHONPATH value from the
This feature can be immensely useful when calling python from scripts
(shell, Makefiles...), in situations for which either multiple PYTHONPATH
values are needed, or where the PYTHONPATH inherited from the parent
environment is not reliable.
Last, the -P option can also be used to expose in the scripts the value of
PYTHONPATH in a highly readable manner.
Typical applications are in development of build, test, and configuration
Comments and suggestions for improvement, and questions are welcome.
fred at arakne.com
fredg at scripps.edu
At present, setting the PYTHONPATH environment variable is the
only method for defining additional Python module search
This PEP introduces the '-P' valued option to the python command
as an alternative to PYTHONPATH.
python -P $SOMEVALUE
will be equivalent to
env PYTHONPATH=$SOMEVALUE python
On Windows 2K:
python -P %SOMEVALUE%
will (almost) be equivalent to
set __PYTHONPATH=%PYTHONPATH% && set PYTHONPATH=%SOMEVALUE%\
&& python && set PYTHONPATH=%__PYTHONPATH%
This option is equivalent to the 'java -classpath' option.
When to use this option
This option is intended to ease and make more robust the use of
Python in test or build scripts, for instance.
A patch implementing this is available from SourceForge:
with the patch discussion at:
More information about the Python-list