I’d like to call all methods of a python object instance with a given set of arguments, i.e. for an object like
class Test():
def a(input):
print "a: " + input
def b(input):
print "b: " + input
def c(input):
print "c: " + input
I would like to write a dynamic method allowing me to run
myMethod('test')
resulting in
a: test
b: test
c: test
by iterating over all test()-methods. Thanks in advance for your help!
Not exactly sure why you want to do this. Normally in something like unittest you would provide an input on your class then reference it inside each test method.
Using inspect and dir.
Output: