Enums & validated models
P28.protocols-abcs.02 · Audience: guest, it-ml, language-pro · Prerequisites: Protocols vs ABCs
Two everyday data-modelling patterns close out the pillar. An enum replaces a scatter of magic strings with a small, closed set of named members — safer, self-documenting, and impossible to mistype. A validated model applies the "parse, don't just store" principle: data is checked and normalised at the boundary, so the rest of your program only ever sees valid values (the idea behind libraries like pydantic).
Ask the mentor about this module
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.
Keeping your files on this device
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.
Rung 1 — model states with an Enum
Loading exercise…
Rung 2 — a validated value object
Loading exercise…
My notes on this module
Loading your notes...