Python Decorator

Noun · Development

Definitions

  1. A higher-order function, applied with the @decorator syntax above a function or class definition, that takes the decorated callable as input and returns a modified or wrapped version of it. Decorators are used to add behavior like caching, authentication checks, logging, or retry logic without modifying the original function's body.

    In plain English: A way to add extra behavior to a Python function — like automatic retrying or logging — by putting a special tag above it instead of rewriting the function itself.

    Example: "I slapped @lru_cache on that recursive Fibonacci function and it went from exponential to instant."

Related Terms