Skip to content

Instantly share code, notes, and snippets.

@khapota
Created February 25, 2016 07:54
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 khapota/e158cebfd54c47644713 to your computer and use it in GitHub Desktop.
Save khapota/e158cebfd54c47644713 to your computer and use it in GitHub Desktop.
Python note
#Assuming module foo with method bar:
import foo
methodToCall = getattr(foo, 'bar')
result = methodToCall()
#As far as that goes, lines 2 and 3 can be compressed to:
result = getattr(foo, 'bar')()
#https://stackoverflow.com/questions/3061/calling-a-function-of-a-module-from-a-string-with-the-functions-name-in-python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment