[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Class initialization with multiple inheritance

-----Original Message-----
From: Barry Scott <barry at barrys-emacs.org> 
Sent: Tuesday, July 16, 2019 11:53 AM
To: Joseph L. Casale <jcasale at activenetwerx.com>
Cc: python-list at python.org
Subject: Re: Class initialization with multiple inheritance

> And here is the MRO for LeftAndRight.
> >>> import m
> LeftAndRight.__init__()
> Left.__init__()
> Right.__init__()
> CommonBase.__init__()
> >>> m.LeftAndRight.__mro__
> (<class 'm.LeftAndRight'>,
>  <class 'm.Left'>,
>  <class 'm.Right'>,
>  <class 'm.CommonBase'>,
>  <class 'object'>)
> >>> 

Thank you DL and Barry, that was very helpful.

It seems that if Base1, 2, or 3 creates its own arguments for the common base
class, this becomes notable and this one case becomes the arguments preserved
and sent to the base regardless of the order of Base1, 2 or 3 inside DerivedClassName.

Now if all three of Base1, 2, or 3 produce their own arguments (discarding those intended
from DerivedClassName, only one is chosen regardless of the order, indicating some
deterministic approach on the name possibly.

Presumably a choice had to be made as to how to handle this case (though the runtime
could have thrown), it would be enlightening to know what logic is utilized in this case.

Thanks a lot!