4 ms·
Python has had proper closures since version 2.2, which is quite old at this point. You can verify this using the following code: def func(): x = [
by bobbyi 15y ago
Python has had proper closures since version 2.2, which is quite old at this point. You can verify this using the following code:
def func():
x = []
def func2():
x.append(1)
return x
return func2
closed = func(); closed(); assert closed() == [1,1]
closed = func(); closed(); assert closed() == [1,1]
- spacemanaki 15y agoThat's what I was referring to as "Java closures".