1.The abc module
abc is the standard-library module behind Python's abstract base classes — it supplies the ABC base class and the @abstractmethod decorator that together stop a class from being instantiated until it fills in every required method.
Key features
- abc supplies ABC (a ready-made base class) and @abstractmethod (a decorator)
- Inheriting from ABC alone changes nothing until a method is marked @abstractmethod
- ABCMeta is the metaclass ABC is built from — used directly only for advanced cases
- abc.abstractmethod must sit closest to the function, decorators apply bottom-up
- register() can declare an unrelated class a "virtual subclass" without inheriting
What abc actually exports
Command
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
...ABC (not ABCMeta) is what actually enforces @abstractmethod — inheriting from ABC is what makes an unimplemented abstract method block instantiation.