Debian Codegraph @

Doc/c-api/method.rst

raw
1 .. highlight:: c
2
3 .. _instancemethod-objects:
4
5 Instance Method Objects
6 -----------------------
7
8 .. index:: pair: object; instancemethod
9
10 An instance method is a wrapper for a :c:type:`PyCFunction` and the new way
11 to bind a :c:type:`PyCFunction` to a class object. It replaces the former call
12 ``PyMethod_New(func, NULL, class)``.
13
14
15 .. c:var:: PyTypeObject PyInstanceMethod_Type
16
17 This instance of :c:type:`PyTypeObject` represents the Python instance
18 method type. It is not exposed to Python programs.
19
20
21 .. c:function:: int PyInstanceMethod_Check(PyObject *o)
22
23 Return true if *o* is an instance method object (has type
24 :c:data:`PyInstanceMethod_Type`). The parameter must not be ``NULL``.
25 This function always succeeds.
26
27
28 .. c:function:: PyObject* PyInstanceMethod_New(PyObject *func)
29
30 Return a new instance method object, with *func* being any callable object.
31 *func* is the function that will be called when the instance method is
32 called.
33
34
35 .. c:function:: PyObject* PyInstanceMethod_Function(PyObject *im)
36
37 Return the function object associated with the instance method *im*.
38
39
40 .. c:function:: PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *im)
41
42 Macro version of :c:func:`PyInstanceMethod_Function` which avoids error checking.
43
44
45 .. _method-objects:
46
47 Method Objects
48 --------------
49
50 .. index:: pair: object; method
51
52 Methods are bound function objects. Methods are always bound to an instance of
53 a user-defined class. Unbound methods (methods bound to a class object) are
54 no longer available.
55
56
57 .. c:var:: PyTypeObject PyMethod_Type
58
59 .. index:: single: MethodType (in module types)
60
61 This instance of :c:type:`PyTypeObject` represents the Python method type. This
62 is exposed to Python programs as ``types.MethodType``.
63
64
65 .. c:function:: int PyMethod_Check(PyObject *o)
66
67 Return true if *o* is a method object (has type :c:data:`PyMethod_Type`). The
68 parameter must not be ``NULL``. This function always succeeds.
69
70
71 .. c:function:: PyObject* PyMethod_New(PyObject *func, PyObject *self)
72
73 Return a new method object, with *func* being any callable object and *self*
74 the instance the method should be bound. *func* is the function that will
75 be called when the method is called. *self* must not be ``NULL``.
76
77
78 .. c:function:: PyObject* PyMethod_Function(PyObject *meth)
79
80 Return the function object associated with the method *meth*.
81
82
83 .. c:function:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
84
85 Macro version of :c:func:`PyMethod_Function` which avoids error checking.
86
87
88 .. c:function:: PyObject* PyMethod_Self(PyObject *meth)
89
90 Return the instance associated with the method *meth*.
91
92
93 .. c:function:: PyObject* PyMethod_GET_SELF(PyObject *meth)
94
95 Macro version of :c:func:`PyMethod_Self` which avoids error checking.