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 ...
Get Python Programming in Context, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.