repeat(times) — a decorator factory: @repeat(3) makes the function run three times per call, returning a list of the results. Three nested functions deep: factory → decorator → wrapper. This nesting is the single most-asked decorator interview question.@repeat(3) on roll; roll()
a list of 3 results
The factory captured times; the wrapper looped.
def repeat(times): def decorator(func): def wrapper(...).
Each layer returns the next inner one.