vuthanhdatt's Second Brain

Home

❯

10 19 Tech

❯

12. Programming Language

❯

12.1 Python

❯

Abstract Base Classes

Abstract Base Classes

Jun 23, 20251 min read

  • python

python

See more:

  • https://www.youtube.com/watch?v=S_ipdVNSFlo
  • https://jellis18.github.io/post/2022-01-11-abc-vs-protocol/

In general there are two use cases for ABCs, as a pure ABC that defines an “interface” and as a tool for code re-use via the Framework Design Pattern or through Mixins.

Pure ABCs (ABC as Interface)

from abc import ABC, abstractmethod
 
class Animal(ABC):
    @abstractmethod
    def walk(self) -> None:
        pass
 
    @abstractmethod
    def speak(self) -> None:
        pass

Graph View

Backlinks

  • Python Protocol

vuthanhdatt © 2025