class A:
def self_method(self):
pass
@staticmethod
def static_method():
pass
a1, a2 = A(), A()
print(a1.self_method == a2.self_method,
id(a1.self_method) == id(a2.self_method),
a1.self_method is a2.self_method)
print(a1.static_method == a2.static_method,
id(a1.static_method) == id(a2.static_method),
a1.static_method is a2.static_method)
Output:
(False, True, False) (True, True, True)
Why is id(a1.self_method) == id(a2.self_method)
True
, but a1.self_method is a2.self_method
is False
? What does it mean? Does python recreate this method/s for every object or not?