I would like to create an array of member functions as a class variable so I can switch throughout the class etc. The following doesn't work
class A:
def b(self):
pass
def c(self):
pass
d = [A.b, A.c]
because A is not yet created. Is there a workaround for that? I've managed to think of two: 1) initialize the class variable in __init__
which I don't like because it will cause it to be reinitialized with every object created; and 2) create it as global variable which I also don't like since it's only used within the class and so should be a class variable.
d
as above, I can have integeri
describe a state, sob
andc
would implement an abstract operation for states 0 and 1 respectively and then I can calld[i](self)
. – Daniil Lantukhov.b()
and.c()
functions (or reinitialise thed
). Are your.b()
and.c()
common throughout the entire class? – TrebledJ