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 names 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. This succession of child-to-parent links is very important for Python when a method is called that was defined in a parent ...
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