Skip to content

Instantly share code, notes, and snippets.

@matchu
Created November 12, 2012 16:38
Show Gist options
  • Save matchu/4060371 to your computer and use it in GitHub Desktop.
Save matchu/4060371 to your computer and use it in GitHub Desktop.
Python pop quiz: closures
multipliers = []
for i in range(3):
multipliers.append(lambda n: n * i)
# What do it do?
print multipliers[0](10)
print multipliers[1](10)
print multipliers[2](10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment