Skip to content

Instantly share code, notes, and snippets.

@saiday
Created July 29, 2015 18:12
Show Gist options
  • Select an option

  • Save saiday/3510fe5c7a2dd8c0bf15 to your computer and use it in GitHub Desktop.

Select an option

Save saiday/3510fe5c7a2dd8c0bf15 to your computer and use it in GitHub Desktop.
Python variable capture
a = [lambda: i for i in xrange(1, 4)]
for f in a:
print f()
//output: 333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment