I have a class member which accepts a function:
class A:
def func(self, method):
...
I want to set a default method since that behavior is desired 99% of the time. This default behavior is static since it does not depend on any members of the class. However, I would like this default method to be private and invisible to the user. Is there any way of accomplishing that?
This is what I have tried:
class A: @staticmethod def __meth(x): pass def func(self, method = meth): passError:
'staticmethod' object is not callableclass A: @staticmethod def __meth(x): pass def func(self, method = A.__meth): passError:
NameError: name 'A' is not definedclass A: @staticmethod def __meth(x): pass def func(self, method = self.__meth): passError:
NameError: name 'self' is not defined
I am using Python 3.5 and do not want to rely on newer features.
@staticmethoddecorator.lambdabe an option?