method-wrapper?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrew cooke

    method-wrapper?

    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.

    Thanks,
    Andrew
  • David

    #2
    Re: method-wrapper?

    What is "method-wrapper"? Google turns up hardly any hits, same with
    searching python.org.
    >
    It probably means that one object (A) contains another object (B).
    When you call certain methods on object A, those methods call methods
    in B, and return B's results to A's caller.
    >From that docstring:
    A.__call__() will run B()
    A.__cmp__(C) will run cmp(B, C)

    etc.

    In other words python code which runs A() will be running the
    equivalent of A.B(), where A can do other things besides calling B()
    if it wants to.

    David.

    Comment

    Working...