10 Inheritance
The third tenet of OOP is inheritance, which is a mechanism for deriving a new class from an existing class. Rather than starting from scratch and potentially duplicating code, inheritance allows a programmer to write code for a new class that extends or differentiates it from an existing class.
Let’s begin with a real-world example that demonstrates what inheritance is basically about. You’re attending culinary school. One of your lessons involves an exhaustive demonstration of making hamburgers. You learn everything that there is to know about the different cuts of meat, the grinding of the meat, the best types of buns, ...
Get Object-Oriented Python 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.