Created
December 25, 2012 07:49
-
-
Save shunwen/4372128 to your computer and use it in GitHub Desktop.
Python local variable declared in for loop stays alive outside the loop.
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
bar = [1,2,3] | |
for foo in bar: | |
foo = foo + 1 | |
break | |
print foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment