Created
February 25, 2016 07:54
-
-
Save khapota/e158cebfd54c47644713 to your computer and use it in GitHub Desktop.
Python note
This file contains 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
#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