๐ŸŽ 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

Pickle
Python's built-in module for serializing and deserializing Python objects into a byte stream for storage or transmission.
Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
Pathlib
A modern Python module providing an object-oriented interface for filesystem paths, replacing os.path operations.
Enum
A built-in class for creating enumerated constants โ€” named groups of related values that improve code readability.
Pip Requirements File
A text file listing Python package dependencies with version specifications for reproducible project installations.
NumPy
A fundamental library for numerical computing in Python, providing efficient multi-dimensional arrays and mathematical operations.
View All Python Terms โ†’