"Super()" confusion

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Feb 9 22:46:52 EST 2009


On Mon, 09 Feb 2009 17:34:05 -0800, Daniel Fetchinson wrote:

...
>>>> Consider whether you really need to use super().
>>>>
>>>> http://fuhm.net/super-harmful/
>>>
>>>Did you actually read that article, understood it, went through the
>>>tons of responses from python-dev team members, including Guido

"Tons" of responses?

I count 16, about a third of which are written by James Knight himself 
(the author of the page you are ranting against), and of the remaining, 
about half are low-to-zero information content, e.g. Tim Peter's joke 
about renaming the page for better marketing value.

It's especially telling that even Guido, the most vocal critic of the 
article, is critical of the *title* but not the content. In his first 
post, he says: "I agree with the best practices in James's 
Conclusion...", and suggested that if the article was called "Multiple 
Inheritance Pitfalls in Python" he'd be much happier.


>> Yes.  Why the knee-jerk reaction?
> 
> Because throwing around that link carries about the same amount of
> information as "perl is better than python", "my IDE is better than
> yours", "vim rulez!", "emacs is cooler than vim", etc, etc.

This is clearly not the case when even the most vocal critic agrees with 
the article's recommendations.


>> I simply pointed out a resource which might be helpful to someone
>> trying to learn to use super.
> 
> It will certainly not be helpful to anyone trying to learn the usage of
> super. 

I've read it, and found it very useful.


> The person who wrote that essay is simply misunderstanding the
> concept, as has been explained countless times by the python dev team.

"Countless". Is that more or less than the "tons of responses" above?


> Hence, it only increases confusion, adds to the noise and spreads false
> alarm.

So you say.


> Honestly, I don't understand how this thing got so much out of control.
> If anyone starts an intelligent question or remark about super, this
> essay is thrown in no matter what. Anyone can explain why?

Because inheritance is potentially confusing. Multiple inheritance is 
even more confusing. Multiple inheritance with diamond diagrams even more 
so, and multiple inheritance with diamond diagrams and non-cooperative 
classes are simply impossible to get right.

Because there are many pitfalls to inheritance in Python, and they aren't 
obvious: who on earth would imagine that calling __init__ or __new__ with 
positional arguments could be dangerous? James Knight's article is a well-
written, understandable description of some of them, in one place and 
with a catchy title. Of course people are going to link to it.

And finally, because people do wrongly get the impression that using 
super will magically make those problems go away. I know this, because I 
was one of them.

(I went through the anger period, sure that Knight must be full of it. 
How could anyone suggest that Guido made a super that isn't perfect? I 
got past that once I realised just how complex inheritance actually is. 
Currently I'm in denial, writing code with super and hoping that it will 
Just Work but not pushing it too hard in case it doesn't.)



-- 
Steven



More information about the Python-list mailing list