tests/basics: Add further tests for nonlocal scoping and closures.

crypto-aes
Damien George 6 years ago
parent 0d10517a45
commit 6cf2a3966e

@ -19,3 +19,25 @@ def f():
g()
return a
print(f())
# nonlocal at inner-inner level (h)
def f():
x = 1
def g():
def h():
nonlocal x
return x
return h
return g
print(f()()())
# nonlocal declared at outer level (g), and referenced by inner level (h)
def f():
x = 1
def g():
nonlocal x
def h():
return x
return h
return g
print(f()()())

Loading…
Cancel
Save