Plugin system; imp module head scratch

Nick Coghlan ncoghlan at
Sun Dec 19 07:41:28 CET 2004

Dave wrote:
> Hi, all,
> I'm trying to implement a simple plugin framework, with some
> unexpected results. I'm using Python 2.3.4 on Windows 2000.
> My script loads plugin packages from a directory (in this
> case its own), and checks a variable defined in the package's
> for information on the plugin.

Packages and modules are really rather different beasts. I wouldn't be surprised 
to find that 'find_module' and 'load_module' behave strangely when used for 

Is there any reason you can't temporarily alter sys.path and use __import__ 
normally? The behaviour of that is generally less quirky.

Anyway, I believe your specific problem is this line:
   return imp.load_module(name, None, '', descr)

Try replacing the empty string in the third argument with the path returned from 
the find_module call. (At the moment, it is pulling in the from the 
current directory, and assigning it to the name you requested)


Nick Coghlan   |   ncoghlan at   |   Brisbane, Australia

More information about the Python-list mailing list