Finding in which class an object's method comes from

Chris Angelico rosuav at gmail.com
Thu Feb 4 04:00:14 EST 2016


On Thu, Feb 4, 2016 at 7:54 PM, ast <nomail at invalid.com> wrote:
> It is strange but I dont have the same result that you:
> (Python 3.4)
>
>>>> class A:
>
> def a(self):pass
>
>>>> class B(A):
> def b(self):pass
>
>>>> class C(B):
> def c(self):pass
>
>>>> obj = C()
>
>>>> obj.a
>
> <bound method C.a of <__main__.C object at 0x02963F90>>

Curious. It appears to have changed between 3.4 and 3.5; my original
copy/paste was from 3.6.

ChrisA



More information about the Python-list mailing list