GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • index
  • modules
  • next
  • previous
  • Python
  • Python 2.7.18 documentation
  • Python/C API Reference Manual
  • Concrete Objects Layer
  • Show Source

This view

  • Original page
  • New address

GeezerVison is showing docs.python.org — Method Objects — Python 2.7.18 documentation

This document is for an old version of Python that is no longer supported. You should upgrade and read the Python documentation for the current stable release.

Method Objects¶

There are some useful functions that are useful for working with method objects.

PyTypeObject PyMethod_Type¶

This instance of PyTypeObject represents the Python method type. This is exposed to Python programs as types.MethodType.

int PyMethod_Check(PyObject *o)¶

Return true if o is a method object (has type PyMethod_Type). The parameter must not be NULL.

PyObject* PyMethod_New(PyObject *func, PyObject *self, PyObject *class)¶
Return value: New reference.

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..

PyObject* PyMethod_Class(PyObject *meth)¶
Return value: Borrowed reference.

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.

PyObject* PyMethod_GET_CLASS(PyObject *meth)¶
Return value: Borrowed reference.

Macro version of PyMethod_Class() which avoids error checking.

PyObject* PyMethod_Function(PyObject *meth)¶
Return value: Borrowed reference.

Return the function object associated with the method meth.

PyObject* PyMethod_GET_FUNCTION(PyObject *meth)¶
Return value: Borrowed reference.

Macro version of PyMethod_Function() which avoids error checking.

PyObject* PyMethod_Self(PyObject *meth)¶
Return value: Borrowed reference.

Return the instance associated with the method meth if it is bound, otherwise return NULL.

PyObject* PyMethod_GET_SELF(PyObject *meth)¶
Return value: Borrowed reference.

Macro version of PyMethod_Self() which avoids error checking.

int PyMethod_ClearFreeList()¶

Clear the free list. Return the total number of freed items.

New in version 2.6.

© Copyright 1990-2020, Python Software Foundation.
The Python Software Foundation is a non-profit corporation. Please donate.
Last updated on Jun 19, 2020. Found a bug?
Created using Sphinx 2.3.1.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.