Saving changes to path

Ethan Furman ethan at stoneleaf.us
Tue Jul 19 15:12:32 EDT 2011


Chess Club wrote:
> Hello,
> 
> I used sys.path.append() to add to the path directory, but the changes
> made are not saved when I exit the compiler. Is there a way to save
> it?

Do you mean saved as in your PATH environment variable is now changed? 
This would be bad.  Not sure about *nix, but on M$ Windows Python's 
sys.path has very little in common with PATH.

Or do you mean saved as in the next time you load Python it remembers 
what you had in sys.path?  Not that I know of.  What you can do, 
however, is set your PYTHONSTARTUP environment variable to some small 
.py script, which Python will run on startup, and put what you want in 
there.  I.e.:

8<-------------------------------------------------------------------
# Python startup file
import sys
sys.path.append('some_folder')
8<-------------------------------------------------------------------

You can change your prompts, etc.

You might also try IPython (http://ipython.scipy.org/).

~Ethan~



More information about the Python-list mailing list