/Doc/c-api/method.rst

http://unladen-swallow.googlecode.com/ · ReStructuredText · 72 lines · 36 code · 36 blank · 0 comment · 0 complexity · 63124bd3bfdbbd3806502295298ee59f MD5 · raw file

  1. .. highlightlang:: c
  2. .. _method-objects:
  3. Method Objects
  4. --------------
  5. .. index:: object: method
  6. There are some useful functions that are useful for working with method objects.
  7. .. cvar:: PyTypeObject PyMethod_Type
  8. .. index:: single: MethodType (in module types)
  9. This instance of :ctype:`PyTypeObject` represents the Python method type. This
  10. is exposed to Python programs as ``types.MethodType``.
  11. .. cfunction:: int PyMethod_Check(PyObject *o)
  12. Return true if *o* is a method object (has type :cdata:`PyMethod_Type`). The
  13. parameter must not be *NULL*.
  14. .. cfunction:: PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)
  15. Return a new method object, with *func* being any callable object; this is the
  16. function that will be called when the method is called. If this method should
  17. be bound to an instance, *self* should be the instance and *class* should be the
  18. class of *self*, otherwise *self* should be *NULL* and *class* should be the
  19. class which provides the unbound method..
  20. .. cfunction:: PyObject* PyMethod_Class(PyObject *meth)
  21. Return the class object from which the method *meth* was created; if this was
  22. created from an instance, it will be the class of the instance.
  23. .. cfunction:: PyObject* PyMethod_GET_CLASS(PyObject *meth)
  24. Macro version of :cfunc:`PyMethod_Class` which avoids error checking.
  25. .. cfunction:: PyObject* PyMethod_Function(PyObject *meth)
  26. Return the function object associated with the method *meth*.
  27. .. cfunction:: PyObject* PyMethod_GET_FUNCTION(PyObject *meth)
  28. Macro version of :cfunc:`PyMethod_Function` which avoids error checking.
  29. .. cfunction:: PyObject* PyMethod_Self(PyObject *meth)
  30. Return the instance associated with the method *meth* if it is bound, otherwise
  31. return *NULL*.
  32. .. cfunction:: PyObject* PyMethod_GET_SELF(PyObject *meth)
  33. Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
  34. .. cfunction:: int PyMethod_ClearFreeList(void)
  35. Clear the free list. Return the total number of freed items.
  36. .. versionadded:: 2.6