Calling the parent __init __ ()

I am using Python 2.6.6.

I have narrowed down my error code to these 2 classes:

class Graph(object):
  def __init__(self, name):
    self.name = name
    self.testme = 3

      

and

class StepPlot(Graph):
  def __init__(self, name):
    print("fdasfdsf")
    print(dir(super(Graph, self)))
    super(Graph, self).__init__(name)

      

Unfortunately, when I instantiate StepPlot

with StepPlot('fdsfa')

, I get the error

TypeError: object.__init__() takes no parameters

Can't we take one parameter?

Looking at

When should super () .__ init __ () be called?

This class organization should work.

Did I miss something? Any help would be appreciated.

+3


source to share


1 answer


The first argument super

must be the class from which it is called:

super(StepPlot, self).__init__(name)

      



For more information see the link.

+3


source







All Articles