I am trying to call fucntions using string value. Here is a simple example of my problem. How to call method(line)
properly? I tried different solutions and got success only with @staticmethod
but this is not what I want.
class A():
def prime(self, key):
line = 'Good'
method = getattr(A, key)
method(line)
def add1(self, string):
print string + ' day!'
def add2(self, string):
print string + ' evening!'
def main():
test = A()
test.prime('add1')
test.prime('add2')
if __name__ == "__main__":
main()