Built-in Functions and Types

super()

Create a proxy for attribute lookup starting after a specified class in the relevant method resolution order (MRO). This supports cooperative multiple inheritance; it does not always select the immediate lexical parent. The zero-argument form in an ordinary method uses compiler-provided class context and its first argument; it does not reliably work inside nested functions. For explicit binding, the object must be an instance of the specified type or a compatible subclass type. Supplying only the type creates an unbound proxy.

Formal Syntax & Structure

python syntaxpython
super()super(type, object_or_type=None, /)

Parameters & Attributes

NameTypeDescription
typetypeClass after which lookup starts; inferred in zero-argument form.
object_or_typeobject | type | NoneInstance or subclass determining MRO; inferred in zero-argument form.

Return Value

super

Proxy delegating explicit attribute access along the MRO.

Working Example

Example Snippetpython
class Base:    def labels(self):        return ["base"]
class Left(Base):    def labels(self):        return ["left"] + super().labels()
class Right(Base):    def labels(self):        return ["right"] + super().labels()
class Combined(Left, Right):    pass
print(Combined().labels())
Python Reference