Having a bit of trouble wrapping my head around this one. I'm sure the answer is simple but its been driving me batty.
In the following code:
class f1():
valnum=1
def A1(self):
self.valnum=5
print self.valnum
def B2(self):
self.valnum=10
print self.valnum
funlist=[A1,B2]
x=f1
x()
x().A1()
x().funlist[1]()
A1()
will execute as expected but not B2()
. Ultimately, I want to have the code call a random function from the list, but the TypeError: B2() takes exactly 1 argument (0 given)
keeps getting in my way. Why is this and what's the best solution.
Thanks.