promptdojo_

Closures and the @ symbol — what AI is doing when it stacks decorators — step 9 of 9

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

full-screen editor opens — close anytime to keep reading.