import from file not on the PYTHONPATH

Mark Hammond MarkH at ActiveState.com
Wed Aug 9 22:30:52 EDT 2000


<staetzsc at my-deja.com> wrote in message
news:8mscaq$6h6$1 at nnrp1.deja.com...
> Is there a way to specify a path for the file that a module is
located
> in?
>
> something like:
> import '/dir1/dir2/mymodule.py'

Try:

import sys
sys.path.insert(0, "/dir1/dir2")
import mymodule
del sys.path[0]

> I'm pretty new to python, so I am scared that this is a really dumb
> question :-)

Nah - it just takes a while to get used to how consenting Python
really is - lets you poke almost anywhere :-)

Mark.






More information about the Python-list mailing list