Created
January 28, 2016 11:08
-
-
Save drj11/f166cae63e846ba6370d to your computer and use it in GitHub Desktop.
close over unassigned variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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