0

I would like to call the __init__ method of the superclass. Here are two way I can think of:

super().__init__(some_arg)  # I am using Python 3

# or like this:
MyBaseClass.__init__(self, some_arg)

What is the preferred way of doing it?

Willem Van Onsem
  • 397,926
  • 29
  • 362
  • 485
Ugur
  • 1,703
  • 2
  • 20
  • 43

1 Answers1

0
super().__init__(*args, **kwargs)   

Perceive you don't pass the "self" - it is inserted automatically.

Super() was first designed in Python 2 to allow classes to be reused as mixins in a class hierarchy in a way that their immediate superclass may change,

jsbueno
  • 86,446
  • 9
  • 131
  • 182