[docs] [issue25772] Misleading descriptions about built-in `super.`

Eryk Sun report at bugs.python.org
Tue Dec 1 11:59:08 EST 2015


Eryk Sun added the comment:

> Just FYI, 'super' is not a type

No, super is a type:

    >>> super
    <type 'super'>

It's one of 3 types defined in Objects/typeobject.c: 

    PyBaseObject_Type : "object"
    PyType_Type       : "type"
    PySuper_Type      : "super"

A super instance (CPython superobject) has the following members: 

     __thisclass__  : the class invoking super()
     __self__       : the instance invoking super()
     __self_class__ : the type of the instance invoking super()

super has a cutsom __getattribute__ (tp_getattro) slot, super_getattro, which proxies attribute access starting at the parent/sibling of __thisclass__ in the __mro__ of __self_class__. 

super even defines a __get__ descriptor (tp_descr_get) method, super_descr_get, though I've never used it as such.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25772>
_______________________________________


More information about the docs mailing list