[Python-Dev] perplexed by mro

Martin v. Loewis martin@v.loewis.de
04 Oct 2002 07:24:40 +0200


Greg Ewing <greg@cosc.canterbury.ac.nz> writes:

> It worries me that when I write a super call, I'll
> never be sure which method is going to be called,
> because someone might inherit me and mess with
> my mro.

That's why it is called a "cooperative super call". Derived classes
can *always* mess it up (be it methods or state), but this approach
provides a pattern for the use case "invoke all of the base methods,
and each of them once".

There are cases where this is useful, and cases where this is not
useful. In cases where it is useful, you have to trust derived classes
to follow the pattern. Since the pattern is easy to follow, this
should not be a problem.

Regards,
Martin