Working with multiple inheritance in Python
We will take advantage of multiple inheritance of classes in Python. First, we will declare the base classes that we will use to create other classes that inherit from them. Then, we will create subclasses that inherit from a pair of classes. We will work with instances of these subclasses that inherit from more than one class. Finally, we will analyze the usage of abstract base classes as another way of achieving the same goal with a more strict structure.
Declaring base classes for multiple inheritance
The following lines show the code for the ComicCharacter
class in Python:
class ComicCharacter: def __init__(self, nick_name): self._nick_name = nick_name @property def nick_name(self): return self._nick_name ...
Get JavaScript : Object-Oriented Programming 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.