reload fails if module not in sys.path
finite.automaton at gmail.com
Fri Oct 21 01:00:35 CEST 2005
So, it turns out that reload() fails if the module being reloaded isn't
Maybe it could fall back to module.__file__ if the module isn't found
... or reload could just take an optional path parameter...
Or perhaps I'm the only one who thinks this is silly:
>>> my_module = imp.load_module(module_name, *imp.find_module(module_name,path))
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named whatever
I guess I could just deal with this by fiddling with sys.path or using
imp.load_module again, but.. um.. I like to complain. ;-)
The context here is that I'm loading user-defined modules as plugins,
and I don't want to keep the plugin directory in sys.path because of
potential module name conflicts.
More information about the Python-list