On the Use and Misuse of Decorators
summary
Asserts that a decorator is an expression evaluated to a function that may do anything not just wrap another function; shows concrete patterns and tools: uses functools and Django examples, implements a run decorator that turns a one-off function into a scoped value, an apply decorator to simulate multi-line lambdas, a builder pattern for nested HTML, and a code-registry like Pants’ rule registry that composes small transformations into working pipelines.
AI-written summary · about
chapters (19)
- 0:00Introduction
- 2:56What are Decorators
- 5:33What is a Decorators
- 6:55The Problem with Namespaces
- 9:08Source of Inspiration
- 10:18The Decorate Pattern
- 10:42The Problem
- 12:01Encapsulation
- 12:56Property
- 14:55Django
- 16:21Scoped Blocks
- 19:02Stream Transformations
- 21:29Builders
- 23:31Code Registry
- 25:51AppRouter
- 26:14Pants
- 27:00Conclusion
- 27:12Summary
- 27:55Outro
related talks
29mHow Decorators Function
02h 15mAll about decorators
02h 21mIntroduction to Decorators: Power Up Your Python Code
24mA Taxonomy of Decorators: A-E
02h 32mIntroduction to Decorators: Power UP Your Python Code
38mDecorators demystified
03h 21mIntroduction to Decorators: Power Up Your Python Code
01mDecorators Demystified
