reload fails if module not in sys.path
Lonnie Princehouse
finite.automaton at gmail.com
Thu Oct 20 19:00:35 EDT 2005
So, it turns out that reload() fails if the module being reloaded isn't
in sys.path.
Maybe it could fall back to module.__file__ if the module isn't found
in sys.path??
... 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))
>>> reload(my_module)
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
mailing list