how to change sys.path?

Ziga Seilnacht ziga.seilnacht at gmail.com
Thu May 25 15:29:33 CEST 2006


Michael Yanowitz wrote:
> Is there something like a .pythoninitrc which can run whenever we start
> Python
> that can load a file with many sys.path.append(), etc?
>   If not is there some way to modify the Python shell constructor and
> destructor?
>
> Thanks in advance:
> Michael yanowitz

Yes, there is the user module:
http://docs.python.org/lib/module-user.html
which you have to explicitly import and which will look for
.pythonrc.py file in user's home directory and execute it.

The other option is a sitecustomize module, which should
be put somewhere on the initial search path. It will be
imported automatically during the interpreter initialization.
See:
http://docs.python.org/lib/module-site.html
for details.

Ziga




More information about the Python-list mailing list