Python Decorators
py-decorators
Question Banks
Community
Python Decorators Explained with Five Real Examples
Decorators stop being magic the moment you see five real ones in a row: timing, caching, auth, retry, and rate limiting. Here is the pattern, the gotchas, and the line where I stop reaching for them.
Context Managers Beyond with open(...)
The `with` statement is a setup-teardown primitive, not a file-handling shortcut. Five context managers I write or use weekly, plus the gotcha that turns a class-based manager into a leak.
A Tracer Decorator With Arg Redaction (Python)
A `@trace()` decorator I bolt onto Python services when the production logs go quiet at the wrong layer. Logs entry, exit, duration, and exceptions, with secret-arg redaction baked in.
The Decorator Pattern vs Language Decorators
The GoF Decorator pattern and Python's @decorator syntax share a name and almost nothing else. What each one really does, where they overlap, and the wrap order that catches everyone.
The 30-Line Debug Print I Keep in My Dotfiles
A pretty-printer for Python objects that I paste into every new project. Shows types, depth, and truncates long containers, so I stop reaching for `pprint` mid-incident.
Python Gotchas That Trip Up Experienced Devs
A 4-question reference set on Python pitfalls that look obvious in retrospect: mutable default arguments, is-vs-equals identity, the GIL's actual behavior, and closure late-binding in comprehensions.
