Created
January 9, 2012 12:55
-
-
Save lprsd/1582833 to your computer and use it in GitHub Desktop.
How do you dynamically import a method from a module in the syspath, which you have as a string.
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
def get_method_from_file(full_path=['credit', 'syndloan', 'importer', 'sql', 'sql', 'loanDealSql']): | |
if len(full_path) == 1: | |
return map(__import__,[full_path[0]])[0] | |
return getattr(get_method_from_file(full_path[:-1]),full_path[-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment