HOWTO Write a Function
summary
Argues that a good function is small and predictable: gather inputs-transform-output at the top middle and bottom, validate early with asserts and early return, expose a dry run flag for non‑destructive checks, use readable names like raw/ignored/_ and pair/left/right for arity, return consistent types (empty list not None) or raise, prefer simple loops over clever one‑liners, avoid overzealous linter rules and gratuitous new language features, and put constants in defaults when that clarifies intent.
AI-written summary · about
chapters (19)
- 0:00Intro
- 1:03Why talk about Code Reviews?
- 2:00Why talk about a function?
- 4:14HOWTO write a function
- 5:05Thinking about function structure
- 7:39Transform
- 8:50All About The Inputs
- 11:34Asserts Add Information
- 12:36Return Early adds confidence
- 13:40The gun on the mantle
- 17:24Names have meaning
- 23:44Return consistently
- 26:42Keep It Together
- 28:09Language Features are an attractive nuisance
- 31:58All effort feels like useful effort
- 33:19Linters are an attractive nuisance
- 35:33Code Reviewer's Smells
- 37:09Summary
- 37:25Thank You PyCon








