[Tutor] What is super for?

Alan Gauld alan.gauld at btinternet.com
Mon Jun 28 19:36:17 CEST 2010


"Adam Bark" <adam.jtm30 at gmail.com> wrote

>> I can't figure out how super(C, self).__init__() is any better than
>> C.__init__(self), is there a preference? Does super do something 
>> special?
>
> Whoops I should really think about these things for a minute first, 
> you
> don't have to know the superclass in advance is presumably the idea?

That's normally the idea behind super(eg in Smalltalk).
Unfortunately the Python version kind of negates that with the need
for the class in the super() call. I think Python v3 has improved this
but I admit is still use the parent.method(self...) style.
To me it is just more obvious and less error prone.

Alan G. 




More information about the Tutor mailing list