Safest manner to extend search path for modules?
Joseph Turian
turian at gmail.com
Tue Jul 26 00:50:20 EDT 2005
Hi,
What is the safest manner to extend search path for modules, minimizing
the likelihood of shooting oneself in the foot?
The system (which includes scripts and their shared modules) may be
checked out in several different locations, but a script in a
particular checked-out version of the system should only use modules
from that checkout location.
e.g. if the system contains a directory scripts/foo/ where all the
scripts are housed, and scripts/modules/ where all the modules are
housed, then is it correct for each script in scripts/foo/ to begin
with:
import sys, os.path
sys.path.append(os.path.join(sys.path[0], "../modules"))
If so, is there a cleaner way of doing this than including the above
text in all scripts?
Thanks,
Joseph
More information about the Python-list
mailing list