Reputation: 381
A functional example (out of class) for a better explanation about what I'm trying to get.
def greet():
print('Hello world')
func = 'greet'
func()
But, if I use same example as a class method, I cannot get the same result. I understand Python is looking for a class method called "func", but I don't know (if is possible to do it), tell to Python that "c.func()" is "c.greet()" really.
class MyApp:
def greet(self):
print('Hello world')
func = 'greet'
c = MyApp()
c.func()
Upvotes: 0
Views: 20