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
abc — Abstract Base Classes
소스 코드: Lib/abc.py 이 모듈은, PEP 3119 에서 설명된 대로, 파이썬에서 추상 베이스 클래스(ABC) 를 정의하기 위한 기반 구조를 제공합니다; 이것이 왜 파이썬에 추가되었는지는 PEP를 참조하십시오. (ABC를 기반으로 하는 숫자의 형 계층 구조에 관해서는 PEP 3141 과 numbers 모듈을 참고하십시오.) The collec...
https://docs.python.org/ko/3/library/abc.html


Seonglae Cho