I'm guessing it's meant for debugging, to see how many times a function is being called. The only thing, is there's no argument to handle the function as a parameter. Once I added that in, and a default for "inc", I could make a demonstration.
def make_acc(func, start=0):
"""accumulator generator """
curr = [start]
def acc(inc=1):
curr[0] += inc
return curr[0]
return acc
@make_acc # use make_acc for debugging purposes
def foo():
return "bar"
print foo() #1
print foo() #2
print foo() #3
print foo() #4
# don't use "make_acc"
def foo():
return "bar"
print foo() #bar
print foo() #bar
print foo() #bar
print foo() #bar So basically, you would append that decorator to any function, and instead of it being called, it will return how times it has been called.