Protocols vs ABCs
P28.protocols-abcs.01 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Records: class vs dataclass vs namedtuple
Where next?
Later in Protocols & ABCs
P28.protocols-abcs.01 · Audience: Guest, IT/ML learner, Language professional · Prerequisites: Records: class vs dataclass vs namedtuple
Later in Protocols & ABCs
How do you say "any object that has these methods" in Python? Two answers:
structural typing with typing.Protocol — conformance by shape, no
inheritance — and nominal typing with abc.ABC — conformance by
subclassing. This track is about choosing between them, and it links forward to
P31 (Typing & Robust Code), where these tools meet mypy.
This first module makes duck typing explicit with a Protocol.
Ask a question about this content. The mentor explains and grounds its answer in what you are studying; asking is recorded as a learning signal, not a grade.
Off by default. The mentor always gets your file; this only decides whether your own copy stays here. Copies live in this browser only - they do not follow you to another device, and clearing site data removes them.
Loading exercise…
Loading exercise…
Loading your notes...