I am trying to run all the functions in my class without typing them out individually.
class Foo(object):
def __init__(self,a,b):
self.a = a
self.b=b
def bar(self):
print self.a
def foobar(self):
print self.b
I want to do this but with a loop, because my actual class has about 8-10 functions.
x = Foo('hi','bye')
x.bar()
x.foobar()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…