MemotivaType hints and typing

What is a Protocol?

Type hints and typing

Audio flashcard · 0:15

Nortren·

What is a Protocol?

0:15

A Protocol, defined in typing, enables structural subtyping or static duck typing. A class is considered a subtype of a Protocol if it implements the required methods and attributes, without explicitly inheriting from it. This combines the flexibility of duck typing with static type checking.
peps.python.org