๐Ÿ Design Patterns with Python
Home Chapters Examples Diagrams Bibliography GitHub โ†—
  1. Home
  2. Patterns in the Wild
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.

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.

Read โ†’
โ† Previous part Idiomatic Python Next part โ†’ Changing Inherited Code
Design Patterns with Python
Prose, diagrams and decks: CC BY 4.0. Sample code: Apache 2.0.
Source on GitHub โ†—  ยท  File an issue โ†—