Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumPythondecorators with argumentsSingle-choice MCQ

Which statement best describes how a parameterized decorator factory like `count_calls(10)` keeps state across calls to the wrapped function?

def count_calls(start): n = start def deco(fn): def wrap(*a, **k): nonlocal n n += 1 return n return wrap return deco @count_calls(10) def f(): pass print(f(), f())