On this page
article
Abstract Base Class
Define interfaces with ABC.
Category: abc
Problem
Define interfaces with ABC.
Solution
class Repository(ABC):
@abstractmethod
def get(self, id): ...
Notes
- Adapt variable names and paths to your project
- Add error handling for production use
- See related chapters in the Learning Path