super()
noun
say it: “SOO-per” /ˈsuːpər/
A Python function that lets a class call a method of the class it inherits from, usually to add to that method rather than replace it.
What does super() do?
super() lets a class call a method from the class it inherits from, usually so it can add to that method instead of replacing it.
class Employee:
def __init__(self, name):
self.name = name
class Manager(Employee):
def __init__(self, name, team):
super().__init__(name) # let Employee set the name
self.team = team
In a sentence
- “Manager's __init__ calls super().__init__(name) so Employee still sets the name.”
- “Using super() kept the parent's setup and added the team list on top.”
Level: Journeyman · More Python terms at this level
Updated