November 2015
Beginner to intermediate
840 pages
26h 30m
English
In Python, it is possible for a class to inherit multiple classes. The difficulty with multiple inheritance is that it becomes difficult to know where behavior is being inherited from.
The classic problem is the diamond inheritance problem, which is illustrated in Figure B.1. If class D inherits from B and C, which in turn inherit from A, and A and C define different values of an attribute, what is the value of the attribute inherited by D?
Figure B.1: Diamond Problem
In modern Python (post version 2.3), the answer is that the x attribute will be True in instances of D. To allow for this, Python linearizes inheritance ...
Read now
Unlock full access