Multiple inheritance and a broken super() chain

Chris Angelico rosuav at gmail.com
Tue Jul 4 08:08:58 EDT 2023


On Tue, 4 Jul 2023 at 22:06, Peter Slížik via Python-list
<python-list at python.org> wrote:
>
> >
> > Also, you might find that because of the MRO, super() in your Bottom
> > class would actually give you what you want.
> >
>
> I knew this, but I wanted to save myself some refactoring, as the legacy
> code used different signatures for Left.__init__() and Right.__init__().

This sounds like a mess that I would not touch. Unless something needs
to be fixed, I wouldn't switch these to use super() - I'd leave them
using explicit parent calls.

However, I would acknowledge somewhere that this will cause
Top.__init__() to be called twice on the same object.

ChrisA


More information about the Python-list mailing list