Loading modules from several directories

Miki Tebeka tebeka at cs.bgu.ac.il
Wed Sep 18 02:47:25 EDT 2002


Hello Eugene,
> Trying to reuse the code I found a problem (with Python or me) where
> if I have for example, a foo package in two separate directories
> (where foo/ contains common files and foo/project_a/ contains
> project-specific files) I can't load from both.
> 
> If I put the common path first in the sys.path it tries to load the
> project-specific stuff from there too. If I try putting the
> project-specific one first it can't find the common stuff.
> 
> Anyone know of a good solution for this problem?
Doesn't

sys.path.append('/somedir/foo')
sys.path.append('/somedir/foo/project_a')
import foostuff
import projectstuff

works?

Miki



More information about the Python-list mailing list