Plugins, or selecting modules to import at runtime

Fredrik Lundh fredrik at pythonware.com
Mon Apr 19 04:14:46 EDT 1999


Gerald Gutierrez <gutier at intergate.bc.ca> wrote:
> I'd like to write a program in Python in which the user can select one of
> several modules to execute through a function that has the same name in all the
> modules. I don't believe "import" lets me pass it a string. There is also
> reload(), but the module to reload must be previously imported.
> 
> This is very similar to plugins like that used in Netscape, Photoshop and the
> GIMP.
> 
> Can someone please give me a hint?

module = __import__("module")

also see:
http://www.pythonware.com/people/fredrik/fyi/fyi06.htm

</F>





More information about the Python-list mailing list