Alan Gauld wrote:
> Having said that I still don't like that mechanism since it makes the 
> behaviour of the subclass depend on the implementation of the 
> superclass. That is, if I choose to create a sub class of someone elses 
> class then a call to super will only work if the other person has 
> written their class with a call to super... not good. Whereas if I call 
> the class init explicitly it works regardless of how the superclass is 
> written.

It's worse than that - with MI if you call __init__() explicitly and the 
base classes call super().__init__(), one of the base class __init__() 
methods will be called twice. See http://fuhm.net/super-harmful/ for an 
example.

super() only works correctly when all the classes involved use it. My 
conclusion is that it is best reserved for the times it is actually 
needed (with diamond MI), and direct calling of the base class method 
should be used everywhere else.

Kent

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to