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

Celery
A distributed task queue for Python that enables asynchronous processing of background jobs and scheduled tasks.
Magic Methods
Special double-underscore methods that define how Python objects behave with built-in operations and functions.
Pip Requirements File
A text file listing Python package dependencies with version specifications for reproducible project installations.
Python Context Variable
A variable that maintains separate values for each execution context, enabling implicit state passing in async code without global variables.
Generator
A function that yields values one at a time using the yield keyword, enabling memory-efficient iteration over large datasets.
Python Descriptors
Objects that define __get__, __set__, or __delete__ methods, controlling how attribute access works on other objects.
View All Python Terms โ†’