Recall
Here are some of the key points in this chapter:
- Using abstract base class definitions is a way to create class definitions with placeholders. This is a handy technique, and can be somewhat clearer than using
raise NotImplementedError
in unimplemented methods. - ABCs and type hints provide ways to create class definitions. An ABC is a type hint that can help to clarify the essential features we need from an object. It's common, for example, to use
Iterable[X]
to emphasize that we need one aspect of a class implementation. - The
collections.abc
module defines abstract base classes for Python's built-in collections. When we want to make our own unique collect class that can integrate seamlessly with Python, we need to start with the definitions from this module. - Creating your own abstract base class leverages the
abc
module. Theabc.ABC
class definition is often a perfect starting point for creating an abstract base class. - The bulk of...