in python: can i pass class method as and a default argument to another class method
- by alex
i want to to pass class method as and a default argument to another class method, so that i can re-use the method as a @classmethod
@classmethod
class foo:
def func1(self,x):
do somthing;
def func2(self, aFunc = self.func1):
# make some a call to afunc
afunc(4)
this why when the method func2 is called within the class aFunc defaults to self.func1, but i can call this same function from outside of the class and pass it a different function at the input.
i get
NameError: name 'self' is not defined