python abc

Creator
Creator
Seonglae Cho
Created
Created
2024 Aug 29 3:39
Editor
Edited
Edited
2024 Aug 29 3:40
Refs
Refs

Abstract Class

 

Abstract factory pattern

The @abstractmethod decorator in Python marks a method as abstract, requiring any class that inherits from the abstract base class to implement that method.
from abc import ABC, abstractmethod class AbstractFactory(ABC): @abstractmethod def create_product_a(self): pass @abstractmethod def create_product_b(self): pass class ConcreteFactory1(AbstractFactory): def create_product_a(self): return ConcreteProductA1() def create_product_b(self): return ConcreteProductB1() # Similar implementation for ConcreteFactory2 # and product classes
 
 
 
 
 

Recommendations