On Aug 12, 4:59 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Mon, 11 Aug 2008 19:19:19 -0300, tow <[EMAIL PROTECTED]> > 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.
Sorry, sloppy terminology on my part, yes, my_module is a package. > > 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? The current directory is actually a subdirectory of /home/tow/test/ my_module, but ".." is not in sys.path (nor is anything containing "..") In any case, if it were a matter of sys.path, surely the imp.find_module call above should succeed? Basically, I had thought that import and imp.find_module used exactly the same search path, but the above example shows that at least in this circumstance they don't; import is picking up additional search paths from somewhere - what am I missing? Toby -- http://mail.python.org/mailman/listinfo/python-list