Plugin system

Josiah Carlson jcarlson at
Sat Oct 30 16:58:27 CEST 2004

Reinhold Birkenfeld <reinhold-birkenfeld-nospam at> wrote:
> Irmen de Jong wrote:
> > Reinhold Birkenfeld wrote:
> > 
> >> How would you implement a plugin system (for a web-based application)?
> > 
> > This is so general a question that I cannot think of anything concrete to answer.
> > Please ask again, with more detail about what you want/need/have in mind.
> Okay, the question is too open: My focus is on how you would structure
> the plugin code (directories, files) and how you would write code to
> load these plugins.

...Have a place for plugins

...Load the plugins on startup
import traceback
import os
for fn in os.listdir('plugins'):
    if fn[:1] != '_' and fn.split('.')[-1] in ('py', 'pyw'):
            globals()[fn] = \
              __import__('plugins.%s'%fn, globals(), locals(), [fn])

Etcetera.  May not be the best, but it will get the job done.

 - Josiah

More information about the Python-list mailing list