[Python-Dev] Things to Know About Super

glyph at divmod.com glyph at divmod.com
Fri Aug 29 22:31:07 CEST 2008


On 06:33 pm, casey at pandora.com wrote:
>On Aug 29, 2008, at 11:46 AM, Michele Simionato wrote:
>>On Fri, Aug 29, 2008 at 6:15 PM, Nick Coghlan <ncoghlan at gmail.com> 
>>wrote:

>>I am very well aware of the collection module and the ABC mechanism.
>>However, you are missing that mixins can be implemented in a single- 
>>inheritance
>>world without the complications of the MRO. See my answer to Alex
>>Martelli in this same thread.

>- super() is tricky to use at best, and its documentation is 
>inaccurate and incomplete. I think it should also be made more clear 
>that super() is really mostly useful for framework developers, 
>including users extending frameworks. Unfortunately many frameworks 
>require you to extend them in order to write useful applications in my 
>experience, so it trickles down to the app developer at times. In 
>short, more correct documentation == good.

>I know I'm probably just stating the obvious here, but I found it 
>therapeutic ;^)

I think this is a problem with this topic.  Everyone writing about 
super() seems to be not just clearing up the documentation issues that 
surround it, but venting from personal frustrations with using it as 
well.  I confess that I have done the same - if not in widely-publicized 
articles, at least on IRC and mailing list posts.

I think it would benefit everyone if this discussion would end up with 
some patches to the library documentation that documented the semantics 
of super() more completely in the reference documentation and the 
"multiple inheritance" area of the tutorial, so that when people *do* 
run in to difficulties there is a very clear, central explanation of 
what it's supposed to do.

Personally I think the thing that really should be pointed out is that 
it may behave in a confusing manner if the signature of the method being 
invoked is not the same on all classes in the same inheritance 
hierarchy.  Theoretical problems aside, 99% of the trouble I've had with 
super() has to do with __init__ methods.

I'll try my hand at such a patch over the weekend, but I'd be grateful 
for some pointers on a "quick start" for that.  I am a complete newb at 
modifying the official documentation, and I seem to recall from a prior 
(failed) attempt that the tools are a bit difficult to work with.


More information about the Python-Dev mailing list