Abstract Base Classes and Type Hints

Learn about the difference between the abstract base classes vs. generic classes and the usage of type hints in Python.

Overview

The concept of an abstract base class is closely tied to the idea of a generic class. An abstract base class is often generic concerning some detail supplied by a concrete implementation.

Most of Python’s generic classes – classes like list, dict, and set – can be used as type hints, which can be parameterized to narrow the domain. There’s a world of difference between list[Any] and list[int]; the value ["a",42,3.14]["a", 42, 3.14] ...