To which I add:
def make_acc(start=0):
def acc(inc):
acc.curr += inc
return acc.curr
acc.curr = start
return acc ... and now the circle is complete <evil grin>
As to where you'd use an accumulator generator - you could use it with a language where functional programming is more pleasant than OO, and you want to store state for (eg) an accounting program - ie you need to store many totals. You could use an accumulator generator for each. Even with an OO program using one probably decreases the chances of bugs - "=" rather than "+=", for instance. You could probably also use it usefully for something domain-specific-ish in (eg) Ruby since you don't need brackets to call it.
-T. *handwave* "These are not the droids you are looking for" *handwave*