functions — and the most-hallucinated bug ai ships9 / 9
closures and the @ symbol — what ai is doing when it stacks decorators
Checkpoint
One last thing before we move on. Same surface as a write step — but the lesson doesn't complete until this passes.
Final drill. Build a decorator factory called prefixed that takes
a string and returns a decorator. The decorator wraps a function so
its return value gets the prefix prepended.
Use it like this:
@prefixed("[INFO] ")
def msg():
return "started"
print(msg()) # [INFO] started
Expected output:
[INFO] started
⌘↵ runs the editor.
Booting Python…
Output
[promptdojo:~]$ _