Abstract base classes in Python

In the previous section, we redesigned the code using the OOP approach. We also demonstrated the use of inheritance by defining a superclass GameUnit, and inheriting from it to create the Knight and OrcRider subclasses. As the last topic in this chapter, let's talk about using abstract base classes in Python.

Tip

This section is intended to provide a basic understanding of ABCs in Python. The discussion here is far from being comprehensive but will be just enough to implement an ABC in our application code. For further reading, check out the Python documentation at https://docs.python.org/3/library/abc.html.

If you are familiar with OOP languages such as Java or C++, you probably already know the concept of an ABC. ...

Get Learning Python Application Development 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.