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