.pth files in working directory
Michael Ekstrand
mekstran at scl.ameslab.gov
Wed Aug 31 09:14:30 EDT 2005
On Wed, 31 Aug 2005 15:07:41 +0200
Peter Maas <peter at somewhere.com> wrote:
> I want a tree
>
> top/
> install.py
> sub1/
> __init__.py
> mod1.py
> sub2/
> mod2.py
>
> where I can do "from sub1 import mod1" in mod2.py no matter what the
> absolute path of top is. To achieve this I start install.py once to
> retrieve the absolute dir of itself (= abspath of top/) and creates
> .pth files with its absolute dir in every subdirectory.
If top/ is the working directory for your Python interpreter, the
problem is solved automatically. Python puts the current working
directory in the default search path. So, if you run
python sub2/mod2.py
then it would work.
HTH,
-Michael
More information about the Python-list
mailing list