Tags

Python Decorators

Python Decorators

0 lessons
1 code snippet
1 question bank
6 community items

py-decorators

Community

6 items
Article

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.

py-decorators
design-patterns
functional-programming
interview-prep
fundamentals

1.1k

18

4.5 (11)

May 11, 2026

by @yunatorres

Article

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.

py-context-managers
py-decorators
exceptions
fundamentals
interview-prep

511

5

4.3 (12)

Apr 5, 2026

by @yukisingh

Code Snippet

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.

Python
py-decorators
debugging
logging
tracing

862

6

4.4 (12)

Mar 17, 2026

by @elisehuang

Article

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.

decorator-pattern
py-decorators
ts-decorators
design-patterns
patterns

662

7

4.2 (13)

Feb 23, 2026

by @kiranpatel

Code Snippet

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
debugging
py-decorators
utility
code-template

994

4

4.5 (13)

Feb 14, 2026

by @owentoure

Question Bundle
Free

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.

Python
py-decorators
py-gil
py-asyncio
interview-prep

378

3

4.4 (13)

Jan 20, 2026

by CodeSnatch