Do all instances of a given class share the same method object? I could not verify this directly using id
. However I think the answer is yes, because the following works:
class A(object):
def f(self, x, d=[]):
d.append(x)
print d
a = A()
b = A()
A.f(a, 3)
a.f(4)
b.f(5)
Out:
[3]
[3, 4]
[3, 4, 5]
Can anyone confirm or infirm this?