Skip to content

Instantly share code, notes, and snippets.

@drj11
Created January 28, 2016 11:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drj11/f166cae63e846ba6370d to your computer and use it in GitHub Desktop.
Save drj11/f166cae63e846ba6370d to your computer and use it in GitHub Desktop.
close over unassigned variable
def box(x):
if x:
a = x
def f():
return a
return f
gives1 = box(1)
print(gives1())
explodes = box(0)
print(explodes())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment