Skip to content

Instantly share code, notes, and snippets.

@pikeas
Created October 9, 2011 15:58
Show Gist options
  • Save pikeas/1273832 to your computer and use it in GitHub Desktop.
Save pikeas/1273832 to your computer and use it in GitHub Desktop.
Unbound variable?
def foo():
a = 10
def _foo():
print a
_foo()
#Outputs 10
def foo():
a = 10
def _foo():
a += 10
print a
_foo()
#Fails with UnboundLocalError: local variable 'a' referenced before assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment