Please see the following example:
class MyClass(object):
@staticmethod
def __myStaticMethod(someArgs):
pass
MY_SPECIAL_METHOD_LIST = [
__myStaticMethod
]
@staticmethod
def someOtherMethod():
m = MyClass.MY_SPECIAL_METHOD_LIST[0]
print(m)
m()
If I now execute the statement MyClass.someOtherMethod()
I get an exception:
<staticmethod object at 0x7fd672e69898>
Traceback (most recent call last):
File "./test3.py", line 25, in <module>
MyClass.someOtherMethod()
File "./test3.py", line 21, in someOtherMethod
m()
TypeError: 'staticmethod' object is not callable
Obviously m
contains a reference to the static method. But I can not call this method. Why? What do I need to change in order to call this method?