Created
November 12, 2012 16:38
-
-
Save matchu/4060371 to your computer and use it in GitHub Desktop.
Python pop quiz: closures
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
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