12.5 Understanding Inheritance
To better understand how inheritance works, we can look behind the scenes at how Python keeps track of instance variables and methods. Each class and instance of a class has some special instance variables that we can use to see how Python finds the right method to call or the right instance variable.
First, the _ _bases_ _ instance variable tells us the name of the superclass of any class. For example, in Session 12.3, you can see that the superclass of Line is GeometricObject. The parent of GeometricObject is ABC (Abstract Base Class). The parent of ABC is object, and object has no parent. By default, Python uses the special class object at the top of the inheritance hierarchy. This chain of child-to-parent links ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access