Skip to content

Instantly share code, notes, and snippets.

@lprsd
Created January 9, 2012 12:55
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 lprsd/1582833 to your computer and use it in GitHub Desktop.
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.
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