Decorators Purpose
Multiple Choice Medium
Question
What is a Python decorator?
Hint
Decorators use @ syntax.
Explanation
A decorator is a function that takes another function and extends its behavior without modifying it directly. Use the @ syntax: @my_decorator above the function definition. Common uses: logging, timing, authentication, caching. Decorators can stack (@decorator2 @decorator1 def f():). They are a powerful metaprogramming tool in Python.
Related Resources
Related Lessons
- Decorators
Learn Python decorators.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.