Now you know how to use protocols in Python. Protocols let you define a type relationship between objects without the burden of inheritance. This relationship is based on the internal structure of classes.
With protocols, you can perform structural subtyping or static duck typing using Python’s type hint system and external static type checkers, like mypy, Pyright, and Pyre.
Resources linked in this lesson:
- Python Protocols: Leveraging Structural Subtyping
- Duck Typing in Python: Writing Flexible and Decoupled Code
In this video course, you’ve: