1.. highlightlang:: c 2 3.. _method-objects: 4 5Method Objects 6-------------- 7 8.. index:: object: method 9 10There are some useful functions that are useful for working with method objects. 11 12 13.. c:var:: PyTypeObject PyMethod_Type 14 15 .. index:: single: MethodType (in module types) 16 17 This instance of :c:type:`PyTypeObject` represents the Python method type. This 18 is exposed to Python programs as ``types.MethodType``. 19 20 21.. c:function:: int PyMethod_Check(PyObject *o) 22 23 Return true if *o* is a method object (has type :c:data:`PyMethod_Type`). The 24 parameter must not be *NULL*. 25 26 27.. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class) 28 29 Return a new method object, with *func* being any callable object; this is the 30 function that will be called when the method is called. If this method should 31 be bound to an instance, *self* should be the instance and *class* should be the 32 class of *self*, otherwise *self* should be *NULL* and *class* should be the 33 class which provides the unbound method.. 34 35 36.. c:function:: PyObject* PyMethod_Class(PyObject *meth) 37 38 Return the class object from which the method *meth* was created; if this was 39 created from an instance, it will be the class of the instance. 40 41 42.. c:function:: PyObject* PyMethod_GET_CLASS(PyObject *meth) 43 44 Macro version of :c:func:`PyMethod_Class` which avoids error checking. 45 46 47.. c:function:: PyObject* PyMethod_Function(PyObject *meth) 48 49 Return the function object associated with the method *meth*. 50 51 52.. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth) 53 54 Macro version of :c:func:`PyMethod_Function` which avoids error checking. 55 56 57.. c:function:: PyObject* PyMethod_Self(PyObject *meth) 58 59 Return the instance associated with the method *meth* if it is bound, otherwise 60 return *NULL*. 61 62 63.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth) 64 65 Macro version of :c:func:`PyMethod_Self` which avoids error checking. 66 67 68.. c:function:: int PyMethod_ClearFreeList() 69 70 Clear the free list. Return the total number of freed items. 71 72 .. versionadded:: 2.6 73