🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Python Intermediate

What is ABC (Abstract Base Class)?

A class that defines a common interface for subclasses by declaring abstract methods that must be implemented.

ABCs enforce contracts — subclasses must implement all abstract methods or they cannot be instantiated. Create ABCs using the abc module: class Shape(ABC): @abstractmethod def area(self): pass. Any subclass must define area().

ABCs are useful for plugin systems, framework extensions, and defining clear interfaces. Built-in ABCs include collections.abc (Iterable, Sequence, Mapping) which define what operations a collection supports.

Related Terms

Python Packaging with Poetry
A modern dependency management and packaging tool for Python that simplifies project setup, versioning, and publishing.
Poetry
A modern Python dependency management and packaging tool that handles virtual environments, locking, and publishing.
Module
A Python file containing definitions and statements that can be imported and reused in other Python programs.
Python Interpreter
The program that reads and executes Python code, translating it into machine instructions at runtime.
GIL (Global Interpreter Lock)
A mutex in CPython that allows only one thread to execute Python bytecode at a time, limiting true parallelism.
Pytest
A testing framework for Python that simplifies writing and running tests with powerful features like fixtures and parametrize.
View All Python Terms →