loading…
Write a decorator count_calls that records how many times the wrapped function was called in a .calls attribute, and keeps the original function's name.
@count_calls
def greet(name):
return "hi " + name
greet("a"); greet("b")
greet.calls -> 2
greet.__name__ -> "greet"
Stuck on the idea itself? The python fluency lesson walks through the pattern from scratch.