About
The environment variable named PYTHONSTARTUP points the name of a file containing your start-up commands.
This file is only read in interactive sessions, not from a script.
If you want to read an additional start-up file from the current directory, you can program this in the global start-up file, e.g. “execfile('.pythonrc')”.
If you want to use the startup file in a script, you must do this explicitly in the script:
import os
if os.path.isfile(os.environ['PYTHONSTARTUP']):
# python 2
execfile(os.environ['PYTHONSTARTUP'])
# python 3
exec(os.environ['PYTHONSTARTUP'])
Articles Related
Documentation / Reference
For more information about PYTHONSTARTUP variable, read the python man page:
$ man python