Question
Which statement about Decorators is the strongest interview answer?
- A decorator wraps or replaces a callable so cross-cutting behavior can be applied without rewriting every call site.
- Decorators is mostly a naming style choice and has little effect on runtime behavior or design tradeoffs.
- Decorators exists mainly to reduce the number of files in a Python project.
- Decorators matters only for frontend scripting and not for backend or automation code.
Hint
Start with the core rule behind Decorators.
Answer and rationale
Correct answer: A. A decorator wraps or replaces a callable so cross-cutting behavior can be applied without rewriting every call site.
A decorator wraps or replaces a callable so cross-cutting behavior can be applied without rewriting every call site. This is the base concept interviewers commonly test first.
Track: Python