Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Created March 4, 2015 05:38
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 Zhangerr/cd0aaa359a550f10cd12 to your computer and use it in GitHub Desktop.
Save Zhangerr/cd0aaa359a550f10cd12 to your computer and use it in GitHub Desktop.
interesting problem regarding frames
"""
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