Where is PyMethod_GET_CLASS in Python 3?
Terry Reedy
tjreedy at udel.edu
Tue Dec 15 16:22:49 EST 2009
On 12/15/2009 11:08 AM, Infinity77 wrote:
> Hi All,
>
> When building C extensions In Python 2.X, there was a magical
> PyMethod_GET_CLASS implemented like this:
>
> #define PyMethod_GET_CLASS(meth) \
> (((PyMethodObject *)meth) -> im_class)
>
> It looks like Python 3 has wiped out the "im_class" attribute.
For bound methods, renamed to __class__ to be consistent with other
objects. Unbound methods were eliminated as extra cruft.
> Which
> is the alternative was to handle this case in Python 3? How do I find
> to which class this particular method belongs to?
A method (unbound) is simply a function accessed as an attribute of a
class. A function can be a method of 0 to n classes, and 'belongs' to
none of them.
Terry Jan Reedy
More information about the Python-list
mailing list