-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
  • 111,943
  • 16
  • 178
  • 202
Lokesh
  • 2,374
  • 6
  • 27
  • 44

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
  • 103,130
  • 11
  • 146
  • 174