~/talk

Easier Classes: Python Classes Without All the Cruft

Talkat PyOhio 2018 · 2018-07-28..07-29· [python, software-architecture]
slides:none on file

Shows how to get rid of boilerplate by using dataclasses (Py3.7), attrs, and namedtuple instead of hand‑rolled classes, demonstrating concrete code for string repr, equality, hashing, iteration (dunder __iter__), immutability (frozen=True), and ordering (order=True or functools.total_ordering). Illustrates pitfalls: namedtuple inherits tuple behaviors you may not want and attrs is third‑party, dataclasses are built in but backportable, and some tiny class uses (matrix, space_age) are simpler as plain functions rather than objects.

AI-written summary · about

  1. 0:00Intro
  2. 2:11Case 1: Month class
  3. 4:53Case 2: Point class
  4. 8:15namedtuple
  5. 15:43dataclasses
  6. 20:10Friendly Class Recipes
  7. 25:26Advanced Recipes
~/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.