method-wrapper?
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Mon Jun 2 23:32:43 EDT 2008
En Sat, 31 May 2008 13:46:45 -0300, andrew cooke <andrew at acooke.org>
escribió:
> Hi,
>
> Within Python (2.5):
>
> >>> help("__str__")
> Help on method-wrapper object:
> __str__ = class method-wrapper(object)
> | Methods defined here:
> |
> | __call__(...)
> | x.__call__(...) <==> x(...)
> |
> | __cmp__(...)
> | x.__cmp__(y) <==> cmp(x,y)
> [...]
>
> What is "method-wrapper"? Google turns up hardly any hits, same with
> searching python.org.
After looking at the code in descrobject.c, I *think* a method-wrapper is
used to create a Python object out of internal methods (stored as C
function pointers in the type structure), as if they were actual Python
methods.
That is, they wrap an internal function pointer (defined in the type)
along with a Python object ("self"), so it can be used in Python code as
it were a normal instance method. But certainly I can be wrong...
--
Gabriel Genellina
More information about the Python-list
mailing list