module import search path strangeness

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Aug 11 23:59:35 EDT 2008


En Mon, 11 Aug 2008 19:19:19 -0300, tow <toby.o.h.white at googlemail.com>  
escribi�:

> I have a python script (part of a django application, if it makes any
> difference) which is exhibiting the following behaviour:
>
> import my_module # succeeds
> imp.find_module("my_module") # fails, raising ImportError
>
> which is completely baffling me. According to sys.path, both should
> fail; the directory containing my_module is not in sys.path (though
> the my_module directory itself is).

my_module is not a module but a package, right? Else I don't understand  
the above statement.

> More puzzlingly, printing out
> my_module.__file__ gives:
>
> /home/tow/test/my_module/../my_module/__init__.pyc
>
> I don't really understand what the ".." is doing in there.
>
> Can someone explain what I'm missing here, it's got me stumped.

Perhaps you have ".." in sys.path? And the current directory happens to be  
/home/tow/test/my_module?

-- 
Gabriel Genellina




More information about the Python-list mailing list