Skip to content

Instantly share code, notes, and snippets.

@thanos
Created June 29, 2011 14:25
Show Gist options
  • Select an option

  • Save thanos/1053933 to your computer and use it in GitHub Desktop.

Select an option

Save thanos/1053933 to your computer and use it in GitHub Desktop.
imports python modules from a package
import os, sys
def load_modules(dir):
package = os.path.realpath(dir)
sys.path.append(package)
for module in [os.path.splitext(fn)[0] for fn in os.listdir(package) if fn.endswith('.py')]:
m = __import__(module)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment