Protocols
Structural subtyping
Interview Relevant: Interface design
Protocols
Duck typing with static checking (Python 3.8+).
Code Examples
python
1from typing import Protocol
2
3class Drawable(Protocol):
4 def draw(self) -> None:
5 ...
6
7def render(obj: Drawable) -> None:
8 obj.draw()