Part 10
2 chapters
Patterns in the Wild
The shortcuts Python offers in place of full patterns (dict dispatch, function tables, EAFP) and the anti-patterns that come from misusing the catalogue.
Chapter 31
Shortcut patterns: dict dispatch, function tables, and EAFP
Replace an if-chain with a table of callables, and read fields and shared state with one try instead of a check and a read.
Chapter 32
Anti-patterns and pattern misuse
A pattern kept after its forces have gone is an anti-pattern. Price the same consignments with a function and with a class for every role, and count what the structure costs.