A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-62.py
1defdeco(fn):
2print("decorating")
3returnfn
4@deco
5defg():
6print("calling")
7print("defined")
8g()
Modern
Answer & explanation
Console output
decorating
defined
calling
Why
The @deco syntax calls deco(g) at definition time, so "decorating" prints before any call. After the def, "defined" prints, and only when g() is invoked does its body run, printing "calling". Decorators execute at decoration time, function bodies at call time.