importing modules from higher level directory

Emile van Sebille emile at fenx.com
Fri Jun 25 18:19:25 EDT 2010


On 6/25/2010 2:20 PM Nathan Huesken said...
> Hi,
>
> Is it somehow possible to import modules from *.py files in a higher
> level directory?
> Intuitively I would do
>
> import ../module
>
> but that does not work.
> How does it work?

IIRC, sys.path controls the search order.  You could insert your 
preferred directory:

   sys.path.insert(0,"/my/import/module/path")

Emile









More information about the Python-list mailing list