source: python/trunk/Doc/c-api/method.rst

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 2.0 KB
RevLine 
[2]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
[391]13.. c:var:: PyTypeObject PyMethod_Type
[2]14
15 .. index:: single: MethodType (in module types)
16
[391]17 This instance of :c:type:`PyTypeObject` represents the Python method type. This
[2]18 is exposed to Python programs as ``types.MethodType``.
19
20
[391]21.. c:function:: int PyMethod_Check(PyObject *o)
[2]22
[391]23 Return true if *o* is a method object (has type :c:data:`PyMethod_Type`). The
[2]24 parameter must not be *NULL*.
25
26
[391]27.. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
[2]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
[391]36.. c:function:: PyObject* PyMethod_Class(PyObject *meth)
[2]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
[391]42.. c:function:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
[2]43
[391]44 Macro version of :c:func:`PyMethod_Class` which avoids error checking.
[2]45
46
[391]47.. c:function:: PyObject* PyMethod_Function(PyObject *meth)
[2]48
49 Return the function object associated with the method *meth*.
50
51
[391]52.. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
[2]53
[391]54 Macro version of :c:func:`PyMethod_Function` which avoids error checking.
[2]55
56
[391]57.. c:function:: PyObject* PyMethod_Self(PyObject *meth)
[2]58
59 Return the instance associated with the method *meth* if it is bound, otherwise
60 return *NULL*.
61
62
[391]63.. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth)
[2]64
[391]65 Macro version of :c:func:`PyMethod_Self` which avoids error checking.
[2]66
67
[391]68.. c:function:: int PyMethod_ClearFreeList()
[2]69
70 Clear the free list. Return the total number of freed items.
71
72 .. versionadded:: 2.6
Note: See TracBrowser for help on using the repository browser.