In python, is there a way of doing the following?
for method in list_of_methods:
class_instance.method(data)
I would think this to be possible in python, since many things are 1st class objects.
Edit: Using some comments below, I tried this:
class Class_Test:
def __init__(self):
pass
def method1(self, data):
print(f"Method 1: {data}")
def method2(self,data):
print(f"Method 1: {data}")
list_of_methods = ["method1","method2"]
for method in list_of_methods:
getattr(Class_Test(),method)("inside for loop")