An Abstract Base Class or ABC mandates the derived classes to implement specific methods from the base class.
It is not possible to create an object from a defined ABC class.
Creating objects of derived classes is possible only when derived classes override existing functionality of all abstract methods defined in an ABC class.
ABC - Example
In Python, an Abstract Base Class can be created using module abc.
Example 1
from abc import ABC, abstractmethod
class Shape(ABC):
@abstractmethod
def area(self):
pass
@abstractmethod
def perimeter(self):
pass
In Example 1, Abstract base class Shape is defined with two abstract methods area and perimeter.