educative.io

Diamond problem

If hybrid inheritance exist in python. does that mean diamond problem also exist in it?

If single inheritance is a good idea then surely multiple inheritance is an even better idea.

There is a problem, however, and it is quite a big problem – the so-called diamond problem.

If you allow multiple inheritances then you have to face the fact that you might inherit the same class more than once.

For example, if B and C inherit from A and D inherits from B and C then it potentially gets two copies of class A:

In Python, as all classes inherit from an object, potentially multiple copies of object are inherited whenever multiple inheritances are used. That is, the diamond problem occurs even in the simplest of multiple inheritances.

You can get a better idea from Educative Edpresso shot