0

My first language(programming) C++,And now I started off with python and I could see unlike java which don't do multiple inheritance to avoid dreaded diamond problem(hopefully), the python seems to have multiple inheritance and as far as I have seen, it doesn't throw ambiguity error when I do multiple inheritance, I knew,C++ has virtual inheritance to avoid diamond prob, and now I am sort off looking how python handles it even it doesn't use any keyword for that(doen't py actually have this problem?)or I am not getting the right scenario to fallen into the diamond prob?

class super:
   x=0
class sub1(super):
   pass
class sub2(super):
   pass
class sub3:(sub1,sub2)
   def prin(self):
       print(self.x)

when I do ob=sub3();ob.prin() things went fine(Hmmmm,why its because of the L->R (sub1,sub2) associativity or any subtle implementation detail behind it?)

RaGa__M
  • 2,550
  • 1
  • 23
  • 44
  • 4
    Required reading: [Python's super considered super](https://rhettinger.wordpress.com/2011/05/26/super-considered-super/). Not sure any answer could explain it better. – Daniel Roseman Jun 16 '16 at 17:39
  • 1
    At least you shouldn't shadow the builtin [`super()`](https://docs.python.org/3/library/functions.html#super) with a class, as it is used to delegate method calls to parents or siblings... – Ilja Everilä Jun 16 '16 at 17:39
  • 1
    See [documentation](https://www.python.org/download/releases/2.3/mro/). – BrenBarn Jun 16 '16 at 17:40

0 Answers0