BuiltinFunctionType.__self__

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jacek Generowicz

    BuiltinFunctionType.__self__

    Where can I find information on the __self__ attribute of builtin
    functions ?
  • Fredrik Lundh

    #2
    Re: BuiltinFunction Type.__self__

    Jacek Generowicz wrote:
    [color=blue]
    > Where can I find information on the __self__ attribute of builtin
    > functions ?[/color]

    it's the same thing as im_self, but for methods/functions
    implemented in C.

    that is, if "x" is a bound method, "x.__self__ " is the object
    that method is bound to:
    [color=blue][color=green][color=darkred]
    >>> x = ["spam"]
    >>> x.count[/color][/color][/color]
    <built-in method count of list object at 0x0083D130>[color=blue][color=green][color=darkred]
    >>> dir(x.count)[/color][/color][/color]
    ['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__getattribute __',
    '__hash__', '__init__', '__module__', '__name__', '__new__', '__reduce__',
    '__reduce_ex__' , '__repr__', '__self__', '__setattr__', '__str__'][color=blue][color=green][color=darkred]
    >>> x.count.__self_ _[/color][/color][/color]
    ['spam']

    for unbound methods (and functions), it's set to None.

    </F>




    Comment

    Working...