I am attempting to use a dict to control function selection from within a class, however, I get this following TypeError:
TypeError: A() missing 1 required positional argument: 'self'
Example code:
class Tt:
def __init__(self):
pass
def A(self):
print("a")
def B(self):
print("b")
def C(self):
print("c")
a_diction={
'0' : A,
'1' : B,
'2' : C
}
def ad(self,data):
self.a_diction[data]()
How should I construct this switch in ad to provide self to both a_diction and to the called method A, B and C?