2008-01-19 18:08:21 -04:00
|
|
|
.. highlightlang:: c
|
|
|
|
|
|
|
|
.. _method-objects:
|
|
|
|
|
|
|
|
Method Objects
|
|
|
|
--------------
|
|
|
|
|
|
|
|
.. index:: object: method
|
|
|
|
|
|
|
|
There are some useful functions that are useful for working with method objects.
|
|
|
|
|
|
|
|
|
|
|
|
.. cvar:: PyTypeObject PyMethod_Type
|
|
|
|
|
|
|
|
.. index:: single: MethodType (in module types)
|
|
|
|
|
|
|
|
This instance of :ctype:`PyTypeObject` represents the Python method type. This
|
|
|
|
is exposed to Python programs as ``types.MethodType``.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: int PyMethod_Check(PyObject *o)
|
|
|
|
|
|
|
|
Return true if *o* is a method object (has type :cdata:`PyMethod_Type`). The
|
|
|
|
parameter must not be *NULL*.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
|
|
|
|
|
|
|
|
Return a new method object, with *func* being any callable object; this is the
|
|
|
|
function that will be called when the method is called. If this method should
|
|
|
|
be bound to an instance, *self* should be the instance and *class* should be the
|
|
|
|
class of *self*, otherwise *self* should be *NULL* and *class* should be the
|
|
|
|
class which provides the unbound method..
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_Class(PyObject *meth)
|
|
|
|
|
|
|
|
Return the class object from which the method *meth* was created; if this was
|
|
|
|
created from an instance, it will be the class of the instance.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
|
|
|
|
|
|
|
|
Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
|
|
|
|
|
|
|
|
Return the function object associated with the method *meth*.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
|
|
|
|
|
|
|
|
Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_Self(PyObject *meth)
|
|
|
|
|
|
|
|
Return the instance associated with the method *meth* if it is bound, otherwise
|
|
|
|
return *NULL*.
|
|
|
|
|
|
|
|
|
|
|
|
.. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
|
|
|
|
|
|
|
|
Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
|
2008-02-14 08:47:33 -04:00
|
|
|
|
|
|
|
|
Merged revisions 74008,74021-74022,74074-74075,74077,74148,74179,74188,74192-74194,74200,74205 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r74008 | benjamin.peterson | 2009-07-15 02:46:42 +0200 (Mi, 15 Jul 2009) | 1 line
update year
........
r74021 | georg.brandl | 2009-07-16 09:33:04 +0200 (Do, 16 Jul 2009) | 1 line
#6486: start with built in functions rather than "built in objects".
........
r74022 | georg.brandl | 2009-07-16 09:38:35 +0200 (Do, 16 Jul 2009) | 1 line
#6481: fix typo in os.system() replacement.
........
r74074 | georg.brandl | 2009-07-18 11:03:10 +0200 (Sa, 18 Jul 2009) | 1 line
#6513: fix example code: warning categories are classes, not instances.
........
r74075 | georg.brandl | 2009-07-18 11:06:31 +0200 (Sa, 18 Jul 2009) | 1 line
#6505: fix typos.
........
r74077 | georg.brandl | 2009-07-18 11:43:40 +0200 (Sa, 18 Jul 2009) | 1 line
#6489: fix an ambiguity in getiterator() documentation.
........
r74148 | ezio.melotti | 2009-07-21 22:18:27 +0200 (Di, 21 Jul 2009) | 1 line
#6536 fixed typo
........
r74179 | ezio.melotti | 2009-07-22 23:08:49 +0200 (Mi, 22 Jul 2009) | 1 line
#6423 has_key -> in
........
r74188 | benjamin.peterson | 2009-07-23 16:25:31 +0200 (Do, 23 Jul 2009) | 1 line
use bools
........
r74192 | georg.brandl | 2009-07-24 18:28:38 +0200 (Fr, 24 Jul 2009) | 1 line
Fix arg types of et#.
........
r74193 | georg.brandl | 2009-07-24 18:46:38 +0200 (Fr, 24 Jul 2009) | 1 line
Dont put "void" in signature for nullary functions.
........
r74194 | georg.brandl | 2009-07-24 22:09:46 +0200 (Fr, 24 Jul 2009) | 1 line
#6564: fix section about the two raise syntaxes.
........
r74200 | georg.brandl | 2009-07-25 15:02:15 +0200 (Sa, 25 Jul 2009) | 1 line
#6571: add index entries for more operators.
........
r74205 | georg.brandl | 2009-07-26 15:36:39 +0200 (So, 26 Jul 2009) | 1 line
#6576: fix cross-refs in re docs.
........
2009-10-27 11:34:21 -03:00
|
|
|
.. cfunction:: int PyMethod_ClearFreeList()
|
2008-02-14 08:47:33 -04:00
|
|
|
|
|
|
|
Clear the free list. Return the total number of freed items.
|
|
|
|
|
|
|
|
.. versionadded:: 2.6
|