๐ŸŽ New User? Get 20% off your first purchase with code NEWUSER20 ยท โšก Instant download ยท ๐Ÿ”’ Secure checkout 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

NumPy
A fundamental library for numerical computing in Python, providing efficient multi-dimensional arrays and mathematical operations.
Exception Handling
A mechanism for managing runtime errors using try, except, else, and finally blocks to prevent program crashes.
Dictionary
A built-in data structure that stores key-value pairs with O(1) average lookup time using hash tables.
Walrus Operator
The := operator that assigns a value to a variable as part of an expression, introduced in Python 3.8.
F-String
A formatted string literal prefixed with f that allows embedding Python expressions directly inside curly braces.
Pytest
A testing framework for Python that simplifies writing and running tests with powerful features like fixtures and parametrize.
View All Python Terms โ†’