Adding paths to sys.path permanently, and another problem...
len-1 at telus.net
Thu Dec 16 21:03:31 CET 2004
Amir Dekel <adekel at ort.org.il> writes:
> Hi everyone,
> I have two problems:
> 1. How can I keep my changes in sys.path after closing the interpreter?
Just how flexible does this need to be? sys.path can easily be altered
at startup from within a sitecustomize module (section 3.28 -- site --
Python Runtime Services -- Python Library Reference) or a module specified
by the PYTHONSTARTUP environment variable (section 3.29 -- user -- Python
Runtime Services). Just have one of these modules append to sys.path any
additional paths you need.
Saving sys.path changes between interpreter runs would be more involved.
On Windows Python loads the initial module search path from the registry.
Python's registry entries are made during installation and are left alone
afterwards. Changing these entries is probably not a good idea. But
if you need sys.path persistence I can try writing an example that does
it automatically using the atexit module and a history file.
<len-l at telus.net>
More information about the Python-list