python call static method from class method code example
Example 1: python call static method in class
# Python methods have a __func__ attribute which, when called
# on a staticmethod, allows it to be executed within a class
# body.
class MyClass:
@staticmethod
def static_method(n: int) -> int:
return n
num = static_method.__func__(10) # Call __func__ with argument
mc = MyClass()
print(mc.num) # Output: 10
Example 2: cls in python
import os
clear = lambda: os.system('cls')