I need to call a class method by name, and pass any arguments. Below is an example of what I am try to do:
class C:
def m(self, s, l=1):
return "result"
def add(self, op, *args, **kwargs):
xx = getattr(C, op)(*args, **kwargs)
print(xx)
ss = C()
ss.add('m', 1, l=5)
This is the error I get:
TypeError: m() missing 1 required positional argument: 's'
How to dynamically pass any argument to any method I call?