Я изучаю Python и копаю глубже в класс super()
.
В файле buildin.py
я вижу:
class super(object):
### some code omitted ###
def __init__(self, type1=None, type2=None): # known special case of super.__init__
"""
super() -> same as super(__class__, <first argument>)
super(type) -> unbound super object
super(type, obj) -> bound super object; requires isinstance(obj, type)
super(type, type2) -> bound super object; requires issubclass(type2, type)
Typical use to call a cooperative superclass method:
class C(B):
def meth(self, arg):
super().meth(arg)
This works for class methods too:
class C(B):
@classmethod
def cmeth(cls, arg):
super().cmeth(arg)
# (copied from class doc)
"""
pass
### some code omitted ###
__self__ = property(lambda self: type(object))
"""the instance invoking super(); may be None
:type: type
"""
__thisclass__ = property(lambda self: type(object))
"""the class invoking super()
:type: type
"""
Я действительно не понимаю, что именно делает property(lambda self: type(object))
.
Я понимаю функцию lambda
и думаю, что (lambda self: type(object))
всегда будет возвращать type
независимо от того, что является self
, поскольку object
наследуется от type
в соответствии с официальным документом.