How can you make user customized settings to Python (e.g. path settings, package imports, etc.)?
user provides this feature.
When imported, the module searches
for your home directory and executes the
file .pythonrc.py. The .pythonrc.py file is
just a Python module with your personal settings.
For instance, my file looks like this:
import sys sys.path.append('/home/jlin/prog/python') sys.path.append('/home/jlin/prog/python/general') import IaGraph from IaGraph import * import Numeric as N import MA del sys
In the first section I
add a few directories to my Python path
in which I have my own packages and modules.
In the second section I import all the functions of the
which allows me to interactively make x-y and contour plots.
Thirdly, I import the
packages, since I use those quite often. Finally, I free up
As I said, adding the line:
to your Python module or script should execute .pythonrc.py. You can also explicitly load the .pythonrc.py file:
at the beginning of your Python modules and scripts. Note that if you're running an interactive session (e.g. you execute Python without any arguments) the .pythonrc.py file is loaded automatically.
Notes: See also Martelli (2003), p. 275.