class Foo(object):
def f(self):
pass
a=Foo()
print(id(Foo.f),id(a.f))
print(a.f,id(Foo.f),id(a.f))
print(str(a.f),id(Foo.f),id(a.f))
output result:
2005918566192 2005885408456
<bound method Foo.f of <__main__.Foo object at 0x000001D30A108B00>> 2005918566192 2005885410056
<bound method Foo.f of <__main__.Foo object at 0x000001D30A108B00>> 2005918566192 2005885408456
question: why are the three outputs different?
from the result, we can see that the _ _ str__ method of the object is not called by itself during print, so what"s the use of _ _ str__?