In addition to s[0] hack, I'd like to suggest the following code. Any comments are highly appreciated: class Scope(object): pass def accumulator(): scope = Scope() scope.n = 0 def f(n): scope.n += n return scope.n return f a1 = accumulator() print a1(1) print a1(2) a2 = accumulator() print a2(10) print a2(20) regards, anton.