Created
June 29, 2011 14:25
-
-
Save thanos/1053933 to your computer and use it in GitHub Desktop.
imports python modules from a package
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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