Commit 6cf2a396 authored by Damien George's avatar Damien George
Browse files

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

parent 0d10517a
......@@ -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()()())
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment