Plugins in Python
Brandon Beck
bbeck at REMOVE-THIS-TO-EMAIL-ME.austin.rr.com
Fri Jun 28 14:40:05 EDT 2002
Erik Max Francis wrote:
> Lars Yencken wrote:
>
>
>>I'm trying to do plugins for a program I'm writing in Python, and I'm
>>not
>>sure how exactly to do it. Basically what I want it to be able to
>>write a
>>module which loads every python file in a directory and stores an
>>instance
>>of each one that loaded successfully.
>
>
> The most obvious implementation is simply to have them each imported as
> modules with __import__, and define some kind of simple
> initialization/shutdown API that will be called upon import.
>
I've recently written something which pretty much does exactly this
using the imp module.
The source is browsable and HTML viewable at:
http://isomorphism.org/~bbeck/bot
You probably want to specifically look at the PluginManager class which
is a class inside of bot.html.
Hope this helps some.
More information about the Python-list
mailing list