On 8/31/2011 12:45 PM, Travis Parks wrote:
I was a little disappointed the other day when I realized that
closures were read-only.

'Were', in 2.x. The standard 2.x workaround for a single nonlocal is to wrap it in a list.

def f():
    i = [0]
    def g(): i[0] += 1
    for j in range(5): g()
    print(i)

f()
# 5

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to