Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created August 6, 2012 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tebeka/3278829 to your computer and use it in GitHub Desktop.
Save tebeka/3278829 to your computer and use it in GitHub Desktop.
find module by name
import sys
import imp
def find_module(name):
names = name.split('.')
path = sys.path
while names:
name = names.pop(0)
file, pathname, desc = imp.find_module(name)
module = imp.load_module(name, file, pathname, desc)
path = getattr(module, '__path__', None)
return module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment