How can I call the function B inside function C, by its name == str(B) only and without using self.B()?
class A:
def B(self):
print('sth')
def C(self):
# I want to call function self.B() in here by its name which is str(B)
The reason why I want to do that is:
class A:
def C(self, person):
if person == "John":
self.John()
elif person == "Ben":
self.Ben()
def John(self):
print("I am john")
def Ben(self):
print("I am Ben")
A("John").C()
Because the person variable must be a string, I want to run the corresponding function of the parameter: person, if I can call the function by its name by some way, I don't need to add the additional if and elif condition in def C.