class A(object):
@staticmethod
def static_fun():
print('A.static_fun')
def fun(self):
print('A.fun', self)
print('#', end='')
self.static_fun()
class B(A):
@staticmethod
def static_fun():
print('B.static_fun')
def fun2(self):
print('B.fun2', self)
print('#', end='')
self.static_fun()
a = A(); a.static_fun(); a.fun()
print('----')
b = B(); b.static_fun(); b.fun(); b.fun2()
Item 26: staticmethod
Posted by Logan Chien