方法对象

There are some useful functions that are useful for working with method objects.

PyTypeObject PyMethod_Type

此实例的 PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType .

int PyMethod_Check ( PyObject  *o )

返回 True 若 o is a method object (has type PyMethod_Type ). The parameter must not be NULL .

PyObject * PyMethod_New ( PyObject  *func , PyObject  *self , PyObject  *class )
返回值:新引用。

Return a new method object, with func being any callable object; this is the function that will be called when the method is called. If this method should be bound to an instance, self should be the instance and class should be the class of self ,否则 self 应该为 NULL and class should be the class which provides the unbound method..

PyObject * PyMethod_Class ( PyObject  *meth )
返回值:借位引用。

Return the class object from which the method meth was created; if this was created from an instance, it will be the class of the instance.

PyObject * PyMethod_GET_CLASS ( PyObject  *meth )
返回值:借位引用。

Macro version of PyMethod_Class() which avoids error checking.

PyObject * PyMethod_Function ( PyObject  *meth )
返回值:借位引用。

Return the function object associated with the method meth .

PyObject * PyMethod_GET_FUNCTION ( PyObject  *meth )
返回值:借位引用。

Macro version of PyMethod_Function() which avoids error checking.

PyObject * PyMethod_Self ( PyObject  *meth )
返回值:借位引用。

Return the instance associated with the method meth if it is bound, otherwise return NULL .

PyObject * PyMethod_GET_SELF ( PyObject  *meth )
返回值:借位引用。

Macro version of PyMethod_Self() which avoids error checking.

int PyMethod_ClearFreeList ( )

Clear the free list. Return the total number of freed items.

2.6 版新增。

上一话题

函数对象

下一话题

文件对象

本页