我正在阅读functional programming - Can you explain closures (as they relate to Python)? - Stack Overflow,在这个回答中有以下代码。
def make_counter():
i = 0
def counter(): # counter() is a closure
nonlocal i
i += 1
return i
return counter
c1 = make_counter()
c2 = make_counter()
print (c1(), c1(), c2(), c2())
# -> 1 2 1 2
我的疑问:ta 说 counter() is a closure ,应该是 counter is a closure ,对吧?