Python | Abstract Classes
An abstract class is a class that contains one or more abstract methods (a method that is declared but contains no implementation). Python on its own doesn't provide abstract classes. Yet, Python comes with a module which provides the infrastructure for defining Abstract Base Classes (ABCs). This module is called
To define an abstract class
from abc import ABC, abstractmethodclass AbstractClassExample(ABC):def __init__(self, value): self.value = value super().__init__()@abstractmethoddef do_something(self):pass
If the class that inherits this abstract base does not provide the concrete implementation of
do_something, then we get an error.