~/talk

Making Data Classes Work for You

Talkat PyCon US 2022 · 2022-04-27..05-03· [python]
slides:none on file

Starts from a concrete problem (an int constrained to 1–10) and shows code that enforces validity by building a small immutable type OneToTen using dataclasses with frozen=True and validation in __post_init__. Shows composition into Person made from FullName BirthDate EmailAddress, uses enums for months, checks ranges (days 1–31, years 1900–2022), and demonstrates the resulting types are usable and prevent invalid states.

AI-written summary · about

  1. 0:00Introduction
  2. 1:07Checking for errors
  3. 4:20Encapsulation
  4. 6:48Data Classes
  5. 9:08Replace Function
  6. 10:29Frozen Objects
  7. 16:08Composing
  8. 18:57enums
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.