calling super()

Finger.Octopus at gmail.com Finger.Octopus at gmail.com
Wed Apr 4 15:22:35 EDT 2007


Hello, I have been trying to call the super constructor from my
derived class but its not working as expected. See the code:

class HTMLMain:
    def __init__(self):
        self.text = "<HTML><BODY>";
        print(self.text);
    def __del__(self):
        self.text = "</BODY></HTML>";
        print(self.text);

class NewPage(HTMLMain):
    def __init__(self):
        print 'derive2 init'
        super(NewPage, self).__init__();


N = NewPage();
del N


And here's the error message I get:

Traceback (most recent call last):
  File "e:/PyEN/inherit.py", line 16, in <module>
    N = NewPage();
  File "e:/PyEN/inherit.py", line 12, in __init__
    super(NewPage, self).__init__();
TypeError: super() argument 1 must be type, not classobj




More information about the Python-list mailing list