[Python-ideas] [Python-Dev] python and super

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Apr 18 01:35:31 CEST 2011


Michael Foord wrote:
> On 17/04/2011 14:09, Nick Coghlan wrote:

>> just so people can
>> fail to think correctly about cooperative super() designs

> I disagree with this categorisation. It is particularly for where you 
> *are* thinking about cooperative super calls.

I think what Nick means is that, although *you* might be
thinking about super calls, the people who wrote the classes
you're using did *not* (otherwise they would have included
the required super calls). So you're trying to mix classes
that weren't designed to be mixed together, which is likely
to lead to many more problems than just missing super calls.

> The current algorithm has 
> no way to express "don't call my parent class but continue the 
> cooperative calls for other base classes".

That's not quite what you're proposing. What you're proposing
is more like "call my parent class, but don't stop if my parent
class doesn't call *its* parent class."

Which still leaves the question of what happens if your parent's
parent turns up later in your own MRO. Your parent says not to
call it, but your MRO says to call it. Who wins, and why?

There's also the question of what to do with return values.
Without an answer to that, this feature would be restricted to
methods that don't return any useful value.

-- 
Greg



More information about the Python-ideas mailing list