Issue 1577: shutil.move() where destination is a directory was doing a
[python.git] / Doc / c-api / method.rst
blobc104f8995ba35df5e0b10def5428d76865c341cf
1 .. highlightlang:: c
3 .. _method-objects:
5 Method Objects
6 --------------
8 .. index:: object: method
10 There are some useful functions that are useful for working with method objects.
13 .. cvar:: PyTypeObject PyMethod_Type
15    .. index:: single: MethodType (in module types)
17    This instance of :ctype:`PyTypeObject` represents the Python method type.  This
18    is exposed to Python programs as ``types.MethodType``.
21 .. cfunction:: int PyMethod_Check(PyObject *o)
23    Return true if *o* is a method object (has type :cdata:`PyMethod_Type`).  The
24    parameter must not be *NULL*.
27 .. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
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..
36 .. cfunction:: PyObject* PyMethod_Class(PyObject *meth)
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.
42 .. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
44    Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
47 .. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
49    Return the function object associated with the method *meth*.
52 .. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
54    Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
57 .. cfunction:: PyObject* PyMethod_Self(PyObject *meth)
59    Return the instance associated with the method *meth* if it is bound, otherwise
60    return *NULL*.
63 .. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
65    Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
68 .. cfunction:: int PyMethod_ClearFreeList(void)
70    Clear the free list. Return the total number of freed items.
72    .. versionadded:: 2.6