def methclass(meth) :
cls = meth.im_class
name = meth.im_func.__ name__
meth = getattr(cls,nam e,None)
for cls in cls.mro():
_meth = getattr(cls,nam e,None)
if _meth is not None and _meth==meth:
result = cls
return result
>>methclass(b.f oo)
<class '__main__.A'>
(Turns out equality bypasses the methodwraper trickery.)
Comment