-2
class subclass(superclass):
    def __init__(self, arg1, arg2):
        superclass.__init__(self, blah1, blah2)

What is the purpose of using superclass.__init__(self, blah1, blah2)? I am a little confused regarding whether to use the last line or not while inheriting a superclass.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210
Lokesh
  • 2,842
  • 7
  • 32
  • 47

1 Answers1

1
superclass.__init__(self,*args,**kwargs)

is essentially equivelent to

super(Myclass,self).__init__(*args,**kwargs)

that is it calls the supers constructor. but it skips the rest of the inheritance stack (I think super() bubbles or something... most of the time i use the first method)

**this is probably an over simplification

Joran Beasley
  • 110,522
  • 12
  • 160
  • 179