How to set default PS1 value for interactive python?
Question: I'm attempting to colorize my python interpreter to help visually separate
text noise. So if I start interactive python it gives me plain text. I can do
this:

    
    
    import sys
    
    sys.ps1 = "\033[0;34m>>> \033[0m"
    sys.ps2 = "\033[1;34m... \033[0m"
    

However if I exit the interpreter and go back in the values revert to their
default, which isn't surprising in the slightest. My question is how would I
save these values and use them as the default?


Answer: If the environment variable `PYTHONSTARTUP` is defined when Python starts (in
interactive mode), Python will read and execute that file. Look at the
`ENVIRONMENT VARIABLES` section of [this
document](http://docs.python.org/using/cmdline.html) for more information.

So if you put your `sys.ps1` commands into `~/.pythonrc.py` and pointed
`PYTHONSTARTUP` at that file...

    
    
    export PYTHONSTARTUP=~/.pythonrc.py
    

...you would be all set.

You may also want to check out [ipython](http://ipython.org/), which is a
Python interactive interpreter with all sorts of fancy features and
customization possibilities.

