Search notes:

Python: super

super()
super(type)
super(type, obj )
super(type, type)
super() allows to call methods in a class's base class.
class A:

      def __init__(self, val):
          self.val = val

      def xyz(self):
          print('A.val = {}'.format(self.val))

class B(A):

      def __init__(self, val, txt):
          super().__init__(val)
          self.txt = txt

      def xyz(self):
          super().xyz()
          print('B.txt = {}'.format(self.txt))


a = A(11)
a.xyz()

b = B(42, 'hello world')
b.xyz()
Github repository about-Python, path: /builtin-functions/super/demo.py

See also

method resolution order.
Python: Built in functions

Index