PDA

View Full Version : graphics.py



i.mehrzad
December 18th, 2008, 02:22 PM
I want graphics.py to be placed there in my file-system so that i can import it from anywhere on my system, rather than a copy of it always being placed along with my program,

unutbu
December 18th, 2008, 03:34 PM
mkdir ~/pybin
mv graphics.py ~/pybin
Edit ~/.profile:


PYTHONPATH=$HOME/pybin
export PYTHONPATH
Log out, log back in to make ~/.profile changes active.

See http://docs.python.org/tutorial/modules.html#the-module-search-path

i.mehrzad
December 18th, 2008, 05:24 PM
Just to ask.
What does export PYTHONPATH actually do. Everything else makes complete sense to me.

unutbu
December 18th, 2008, 05:29 PM
export is a bash command which makes the environment variable (PYTHONPATH) known to subsequently executed commands (outside of the ~/.profile file).

Type

help export
to learn more about export (help works for any bash command).

digitalvectorz
December 18th, 2008, 06:33 PM
you can also programmatically set it up:



import sys
sys.path.append('/some/path/to/graphics.py')


*note that you're appending an absolute path (/home/user/graphics.py), not a relative path (~/graphics.py)