Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created March 1, 2013 19:18
Show Gist options
  • Select an option

  • Save jaytaylor/5067034 to your computer and use it in GitHub Desktop.

Select an option

Save jaytaylor/5067034 to your computer and use it in GitHub Desktop.
One-liner for dynamically importing a class from a module.
imp = lambda path: reduce(lambda module, next: getattr(module, next), path.split('.')[1:], __import__(path[0:path.index('.')]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment