Sometimes I don't know what will be operated by user.
class User(object):
...
def get_name(self):
return self.name
def get_age(self):
return self.age
operation = "http://localhost:8080/user/get_name".split('/')[-1]
user = User(...)
As you see, the operation
is a variable name is as same as the class attribute.
I try:
eval('user.{}'.format(operation))
It can run. But it looks very appropriate
Now I want to handle it via a way like user.operation
How did I achieve it ?