Python
Intermediate
What is Python ABC Module?
The Abstract Base Classes module that enables defining interfaces and abstract methods that subclasses must implement.
The abc module provides infrastructure for defining abstract base classes in Python. Classes inheriting from ABC with methods decorated with @abstractmethod cannot be instantiated directly — subclasses must implement all abstract methods. This enforces interface contracts at instantiation time rather than at method call time. ABCs are used extensively in Python's standard library: collections.abc defines Iterable, Mapping, Sequence interfaces. Custom ABCs enable type checking with isinstance() and designing frameworks where plugins must implement specific methods. The __subclasshook__ method allows virtual subclass registration without actual inheritance.