Python super() Function


Use the super() Function

Python also has a super() function that will make the child class inherit all the methods and properties from its parent:

Example

class Student(Person):
  def __init__(self, fname, lname):
    super().__init__(fname, lname)
Try it Yourself »

By using the super() function, you do not have to use the name of the parent element, it will automatically inherit the methods and properties from its parent.



Copyright 1999-2023 by Refsnes Data. All Rights Reserved.