Skip to content

Instantly share code, notes, and snippets.

@shunwen
Created December 25, 2012 07:49
Show Gist options
  • Save shunwen/4372128 to your computer and use it in GitHub Desktop.
Save shunwen/4372128 to your computer and use it in GitHub Desktop.
Python local variable declared in for loop stays alive outside the loop.
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