[Python-Dev] Things to Know About Super

Michele Simionato michele.simionato at gmail.com
Fri Aug 29 06:44:24 CEST 2008


On Fri, Aug 29, 2008 at 6:22 AM, Phillip J. Eby <pje at telecommunity.com> wrote:
> You're right, let's abolish inheritance, too, because then you might have to
> read more than one class to see what's happening.

You are joking, but I actually took this idea quite seriously. Once
(four years ago or so) I did implement an object system from scratch
in Scheme, completely without inheritance, to see how far it would
go. It didn't go far, of course (nor I did expect it to go very far) but
at least I learned exactly what (single) inheritance was good for.
OTOH, for what concerns multiple inheritance, I am still not
convinced it is really worth it. I mean, the MRO is beautiful,
elegant and all that on paper, but on real-life code things as different,
especially from the side of the users of frameworks heavily
based on inheritance.

> Naturally, if you can design a system to use delegates instead of class
> hierarchy to represent a chain of responsibility, it might well be an
> improvement.  But there are tradeoffs, and no matter what you are going to
> end up coding chains of responsibility.

Agreed, it is all about tradeoffs. We have a different opinion on what
a good tradeoff is in this case, but that's fine. I guess it depends
on personal experience and the kind of code one has to work with.
For instance I never had to integrated different frameworks
using different metaclasses in my daily work, so I don't see
a very strong case for classy_class over class decorators,
but I could change my mind in the future, who knows?

Anyway, It would be nice to have a good simple *real life*
use case of cooperative inheritance not involving metaclasses,
suitable for a beginners' tutorial about super, but I haven't
found one yet :-(

          M.S.


More information about the Python-Dev mailing list