Skip to main content

What are Python decorators?

Entry Python
Quick Answer Decorators are functions that wrap another function to add behavior without modifying its code. Applied with @decorator syntax above function definition. Common uses: logging, timing, authentication, caching. A decorator takes a function, returns a new function that calls the original. Use functools.wraps(func) to preserve the wrapped function's name and docstring.

Answer

Decorators modify functions dynamically.
Use @decorator syntax.
Common for logging, authorization, caching.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice