Re: Multiple inheritance and a broken super() chain

2023-07-05 Thread Alan Gauld via Python-list
On 05/07/2023 01:27, Chris Angelico via Python-list wrote: >> So I'm curious about how big this "big problem with MI" is in > > Who said it's a big problem with MI? I think it's a very common perception, particularly with newer programmers who have never used it in anger. Any time anyone discus

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Chris Angelico via Python-list
On Wed, 5 Jul 2023 at 10:31, Greg Ewing via Python-list wrote: > > On 5/07/23 10:33 am, Alan Gauld wrote: > > (*) C++ is the odd one out because it doesn't have GC, but then > > neither does it have an Object superclass so very often MI in C++ > > does not involve creating diamonds! And especially

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Greg Ewing via Python-list
On 5/07/23 10:33 am, Alan Gauld wrote: (*) C++ is the odd one out because it doesn't have GC, but then neither does it have an Object superclass so very often MI in C++ does not involve creating diamonds! And especially if the MI style is mixin based. Even if all your mixins have empty construc

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Chris Angelico via Python-list
On Wed, 5 Jul 2023 at 08:35, Alan Gauld via Python-list wrote: > > On 03/07/2023 19:39, Chris Angelico via Python-list wrote: > > On Tue, 4 Jul 2023 at 03:39, Peter Slížik via Python-list > >> The legacy code I'm working with uses a classic diamond inheritance. > > > What happens when Top is initi

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Alan Gauld via Python-list
On 03/07/2023 19:39, Chris Angelico via Python-list wrote: > On Tue, 4 Jul 2023 at 03:39, Peter Slížik via Python-list >> The legacy code I'm working with uses a classic diamond inheritance. > What happens when Top is initialized twice? This seems like a problem > waiting to happen, and when you

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Chris Angelico via Python-list
On Tue, 4 Jul 2023 at 22:06, Peter Slížik via Python-list 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 si

Re: Multiple inheritance and a broken super() chain

2023-07-04 Thread Peter Slížik via Python-list
> > 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__(). I realized the formatting of

Re: Multiple inheritance and a broken super() chain

2023-07-03 Thread Mats Wichmann via Python-list
On 7/3/23 12:13, Mats Wichmann via Python-list wrote: To natter on a bit, and possibly muddy the waters even further... Now, as I see it, from the super()'s point of view, there are two inheritance chains, one starting at Left and the other at Right. But *Right.__init__()* is called twice. No:

Re: Multiple inheritance and a broken super() chain

2023-07-03 Thread Chris Angelico via Python-list
On Tue, 4 Jul 2023 at 03:39, Peter Slížik via Python-list wrote: > > Hello. > > The legacy code I'm working with uses a classic diamond inheritance. Let me > call the classes *Top*, *Left*, *Right*, and *Bottom*. > This is a trivial textbook example. The classes were written in the > pre-super() e

Re: Multiple inheritance and a broken super() chain

2023-07-03 Thread Mats Wichmann via Python-list
On 7/3/23 12:01, Richard Damon via Python-list wrote: On 7/3/23 1:38 PM, Peter Slížik via Python-list wrote: Hello. The legacy code I'm working with uses a classic diamond inheritance. Let me call the classes *Top*, *Left*, *Right*, and *Bottom*. This is a trivial textbook example. The classe

Re: Multiple inheritance and a broken super() chain

2023-07-03 Thread Richard Damon via Python-list
On 7/3/23 1:38 PM, Peter Slížik via Python-list wrote: Hello. The legacy code I'm working with uses a classic diamond inheritance. Let me call the classes *Top*, *Left*, *Right*, and *Bottom*. This is a trivial textbook example. The classes were written in the pre-super() era, so all of them ini