Last active
May 12, 2016 05:51
-
-
Save dbrattli/a30d6c47c00c01a1b3943dd314bb85da to your computer and use it in GitHub Desktop.
Closing over loop variable considered harmful
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
actions=[] | |
for x in range(10): | |
actions.append(lambda: print(x)) | |
for act in actions: | |
act() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment