0

Type 1 :

class Demo(object):
"""docstring for Demo"""
    def __init__(self, arg):
        super(Demo, self).__init__()
        self.arg = arg

or Type 2 :

class Demo(object):
    def __init__(self, arg):
        self.arg = arg

I have used Type 2 and i have no doubts in it.
what does super(Demo, self).__init__() mean in Type 1 ? and What does it do ?

Srivishnu
  • 759
  • 1
  • 6
  • 15
  • 1
    This is explained in the official tutorial section on classes. The linked question's answers may have additional useful information, but don't skip reading the tutorial. The short version is: `super` lets the base class do _its_ initialization. For `object` it doesn't matter, because it doesn't have any initialization to do, but for most other superclasses it will, so it's a good habit to always get into (in case, e.g., you later change this to `class Demo(MyIntermediateClass):`). – abarnert May 06 '15 at 17:10
  • 1
    Also see [Python's `super()` considered super!](https://rhettinger.wordpress.com/2011/05/26/super-considered-super/) – abarnert May 06 '15 at 17:12

0 Answers0