Created
March 4, 2015 05:38
-
-
Save Zhangerr/cd0aaa359a550f10cd12 to your computer and use it in GitHub Desktop.
interesting problem regarding frames
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
""" | |
What's the different in output between the following two functions? | |
HINT: look at environment diagram | |
""" | |
L = [] | |
for i in range(10): | |
L.append(lambda: i) | |
for z in L: | |
print(z()) | |
L = [] | |
for i in range(10): | |
L.append((lambda x: lambda: x)(i)) | |
for z in L: | |
print(z()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment