calling super()

attn.steven.kuo at gmail.com attn.steven.kuo at gmail.com
Wed Apr 4 15:33:09 EDT 2007


On Apr 4, 12:22 pm, Finger.Octo... at gmail.com wrote:
> 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:


The error message is trying to tell
you that 'super' should be used with
new style classes.

So,

class HTMLMain:

should be

class HTMLMain(object):

--
Hope this helps,
Steven




More information about the Python-list mailing list