[Pythonmac-SIG] comp.lang.python ?: startup script

Donovan Preston dsposx@mac.com
Fri, 7 Mar 2003 10:08:11 -0800


On Friday, March 7, 2003, at 08:21 AM, JR wrote:

> Is there a method whereby one can trigger a script at interpreter init
> without going to extremes like hacking into site.py et al.?
>
> Inquisitively yours,
> JR

There are two techniques I like to use. One is to set the PYTHONSTARTUP 
environment variable which, surprise surprise, runs the specified 
script each time you start the interpreter. :) The other, which you 
should note overrides the PYTHONSTARTUP value, is to pass the script on 
the command line like so:

python -i foo.py

Which runs foo.py and then drops you into the interpreter afterwards.

Of course, I'm assuming you're using raw unix python or Framework 
python -- for OS 9/CFM Carbon MacPython the process is probably 
different, and I don't know what it is.

Donovan