View Single Post
Old Aug 13th, 2006, 12:00 PM   #3
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 856
Rep Power: 3 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
I understand how the accumulator function works, but how come the curr variable has to be a list? Why doesn't the following work?

def make_acc(start=0):
    """accumulator generator """
    curr = start
    def acc(inc):
        curr += inc
        return curr
    return acc
I get the error "UnboundLocalError: local variable 'curr' referenced before assignment".
titaniumdecoy is offline   Reply With Quote