Inheritance

PEP 367 - New Super [Py2.6]

PEP 3135 - New Super [Py3.0]

https://www.programiz.com/python-programming/methods/built-in/super

SUPER

The super() builtin returns a proxy object (temporary object of the superclass) that allows us to access methods of the base class.

In Python, super() has two major use cases:
(1) allows us to avoid using the base class name explicitly,
(2) working with Multiple Inheritance.


#class Bird(object):   # Py2, new style classes
class Bird:          # Py3
    def __init__(self, name):
        print("{} is a bird.".format(name))

class Parrot(Bird):
    def __init__(self, name, food):
        #Bird.__init__(self, name)   # old style
        #super(Parrot, self).__init__(name)   # Py2 and Py3
        super().__init__(name)   # Py3, the name Bird is not used
        print("{} is a parrot and it likes {}.".format(name, food))

parrot = Parrot("Ara", "seeds")
# Ara is a bird.
# Ara is a parrot and it likes seeds.