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

Docstring
A string literal placed as the first statement in a module, class, or function to document its purpose and usage.
GIL (Global Interpreter Lock)
A mutex in CPython that allows only one thread to execute Python bytecode at a time, limiting true parallelism.
Uvicorn
A lightning-fast ASGI server for Python, commonly used to serve FastAPI and other async web applications.
Python Wheel
A built distribution format (.whl) that allows faster installation of Python packages by avoiding the need for compilation.
Scikit-learn
The most popular Python machine learning library providing simple and efficient tools for data analysis and modeling.
Magic Methods
Special double-underscore methods that define how Python objects behave with built-in operations and functions.
View All Python Terms โ†’