Skip to content

Instantly share code, notes, and snippets.

@andrewjennings
Created March 14, 2012 15:16
Show Gist options
  • Save andrewjennings/2037181 to your computer and use it in GitHub Desktop.
Save andrewjennings/2037181 to your computer and use it in GitHub Desktop.
Grab a python module by name
def _get_service_by_name(self, service_name):
module, separator, class_name = service_name.rpartition('.')
m = __import__( module )
path = service_name.split('.')[1:]
for p in path:
m = getattr(m, p)
return m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment