Skip to content
క
kagitha
/
quiz
/
python-decorators
Subscribe
Index
⌘K
JAVA NOTEBOOK · QUIZ 22 · INTERMEDIATE
Python decorators vs Java annotations
QUESTION 01 / 04
What does @timer above def answer(): mean?
A
Metadata that a framework reads later
B
answer = timer(answer), run when Python reads the def
C
A comment for documentation tools
D
answer is called every time timer is called
SCORE SO FAR · 0 / 0
Share this quiz ↗
What does @timer above def answer(): mean?
— answer = timer(answer), run when Python reads the def. A decorator is a function call. Python passes your function to timer and binds the name answer to whatever timer returns.
How is @app.get("/health") different from Spring's @GetMapping("/health")?
— The Python one is code that registers the function right away; the Java one is metadata read later. A Java annotation does nothing until a framework reads it. A Python decorator runs when the def is executed and, here, registers the route.
Why use @functools.wraps(func) inside your own decorator?
— It keeps the original function's name and docstring on the wrapper. Without it, the decorated function is named wrapper in logs, tracebacks and tool schemas.
With @a on top of @b on top of def f, which decorator applies first?
— @b, the one closest to the def. Decorators apply from the bottom up. f = a(b(f)).
kagitha
Close
✕
Search everything — articles, videos, chapters, agents, books
01
AI
02
Java
03
System Design
04
Series
05
Manga
06
The Lab
07
Videos
08
Quizzes
09
Books
10
Resume