Created
June 22, 2011 20:33
-
-
Save pbdeuchler/1041093 to your computer and use it in GitHub Desktop.
Trying to dynamically import modules/call methods within said modules
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 | |
pathname = os.path.dirname(sys.argv[0]) + "/" | |
pathname = pathname + "/modules/" | |
__modules__ = [ os.path.basename(f)[:-3] for f in glob.glob(os.path.dirname(pathname)+"/*.py")] | |
for module in __modules__: | |
__import__(module) | |
#calling checkMe() | |
for module in __modules__: | |
m = sys.modules[__name__][module] | |
getattr(m, 'checkMe').__call__() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment