On 5/19/19, Arup Rakshit <a...@zeit.io> wrote: > > class Dad: > def can_i_take_your_car(self): > print("No...") > > class Mom(Dad): > def can_i_take_your_car(self): > print("Asking your dad...") > > class Victor(Mom, Dad): > def can_i_take_your_car(self): > print("Asking mom...") > > class Pinki(Mom, Dad): > def can_i_take_your_car(self): > print("I need it today..") > > class Debu(Pinki, Victor): > def can_i_take_your_car(self): > super(Victor, self).can_i_take_your_car() > > In this piece of code: > > print(Debu().can_i_take_your_car()) > > Why the above call prints "Asking your dad…” but not " print("Asking mom…”)” > although can_i_take_your_car is defined inside the class Victor ?
Victor comes after Pinki in the MRO: >>> super(Debu, Debu()).can_i_take_your_car() I need it today.. >>> super(Pinki, Debu()).can_i_take_your_car() Asking mom... >>> super(Victor, Debu()).can_i_take_your_car() Asking your dad... >>> super(Mom, Debu()).can_i_take_your_car() No... > Last question: Why duplicate PEPs for the same thing > https://www.python.org/dev/peps/pep-0367/ and > https://www.python.org/dev/peps/pep-3135/#specification ? Which one to read > when such duplicate exists? See https://www.python.org/dev/peps/pep-0367/#numbering-note and https://www.python.org/dev/peps/pep-3135/#numbering-note. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor