Skip to content

Instantly share code, notes, and snippets.

@tsudot
Created June 1, 2012 05:07
Show Gist options
  • Save tsudot/2848986 to your computer and use it in GitHub Desktop.
Save tsudot/2848986 to your computer and use it in GitHub Desktop.
loading modules dynamically
def load(self):
self.plugins = ['monit', 'opensips', 'sshd']
self.fetch_config()
plugins = {}
for plugin in self.plugins:
# get_class_name returns the class nume for that plugin,
# for a new plugin we need to have a standard class name
# for example the module name capitalized with the first word
plugins[plugin] = getattr(__import__(plugin), get_class_name(plugin))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment