add1f0fe356b55c3cf24fa799ae6877be2e9c30d
[profile/ivi/python.git] / Doc / c-api / method.rst
1 .. highlightlang:: c
2
3 .. _method-objects:
4
5 Method Objects
6 --------------
7
8 .. index:: object: method
9
10 There are some useful functions that are useful for working with method objects.
11
12
13 .. cvar:: PyTypeObject PyMethod_Type
14
15    .. index:: single: MethodType (in module types)
16
17    This instance of :ctype:`PyTypeObject` represents the Python method type.  This
18    is exposed to Python programs as ``types.MethodType``.
19
20
21 .. cfunction:: int PyMethod_Check(PyObject *o)
22
23    Return true if *o* is a method object (has type :cdata:`PyMethod_Type`).  The
24    parameter must not be *NULL*.
25
26
27 .. cfunction:: 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 .. cfunction:: 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 .. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
43
44    Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
45
46
47 .. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
48
49    Return the function object associated with the method *meth*.
50
51
52 .. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
53
54    Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
55
56
57 .. cfunction:: 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 .. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
64
65    Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
66
67
68 .. cfunction:: int PyMethod_ClearFreeList()
69
70    Clear the free list. Return the total number of freed items.
71
72    .. versionadded:: 2.6