osdir.com


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

super or not super?


On Mon, Jul 15, 2019 at 10:51 AM Paulo da Silva
<p_s_d_a_s_i_l_v_a_ns at netcabo.pt> wrote:
>
> ?s 15:30 de 12/07/19, Thomas Jollans escreveu:
> > On 12/07/2019 16.12, Paulo da Silva wrote:
> >> Hi all!
> >>
> >> Is there any difference between using the base class name or super to
> >> call __init__ from base class?
> >
> > There is, when multiple inheritance is involved. super() can call
> > different 'branches' of the inheritance tree if necessary.
> > ...
>
> Thank you Jollans. I forgot multiple inheritance. I never needed it in
> python, so far.
>

Something to consider is that super() becomes useful even if someone
else uses MI involving your class. Using super() ensures that your
class will play nicely in someone else's hierarchy, not just your own.

ChrisA