3 · 15 lessons
Clean code in Python
Names, small functions, guard clauses, value objects and clear errors: refactor working code so others can read and change it.
Progress and your code are kept in this browser only.
- 1Names that say what they mean
- 2Small functions with one job
- 3One level of abstraction
- 4Guard clauses and early return
- 5Replacing flag arguments
- 6Constants and enums
- 7Comments versus clear code
- 8Duplication and when to remove it
- 9From primitives to value objects
- 10Prefer immutable values
- 11Pure functions, effects at the edges
- 12Exceptions instead of error codes
- 13One reason to change
- 14Open for extension
- 15Type hints as documentation