On this page
super
Prev: sum | Up: __builtins__ | Next: tuple
Rel: classmethod, property, staticmethod, Python Object, MRO & Initialization Dunder Flow, Object-Oriented Programming (OOP)
Ref: docs.python.org — super
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import super
Overview & Signature
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
Usage
class Base:
def greet(self) -> str: return "hello"
class Loud(Base):
def greet(self) -> str: return super().greet().upper()
assert Loud().greet() == "HELLO"
Gotchas
- Follows the class MRO, NOT just the direct parent: Enables cooperative multiple inheritance (e.g., mixins).
- Zero-arg
super()works inside methods in Python 3; no need to writesuper(Loud, self).
REPL Inspect
help(super)
Linked from
- tuts/python3/__builtins__
- tuts/python3/__builtins__/__builtins__
- tuts/python3/__builtins__/classmethod
- tuts/python3/__builtins__/property
- tuts/python3/__builtins__/staticmethod
- tuts/python3/__builtins__/sum
- tuts/python3/__builtins__/tuple
- tuts/python3/python metaprogramming
- tuts/python3/tutorials/advanced_python_internals/python_object_mro_and_initialization
- tuts/python3/tutorials/intermediate_python_and_software_engineering/object_oriented_programming
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/classmethod Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/property Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/staticmethod Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/sum Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/tuple Linked here; links to this page; shared tags: #builtins
- tuts/python3/tutorials/advanced_python_internals/python_object_mro_and_initialization Linked here; links to this page
- tuts/python3/tutorials/intermediate_python_and_software_engineering/object_oriented_programming Linked here; links to this page
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/python metaprogramming links to this page