Skip to content

Instantly share code, notes, and snippets.

@dangra
Created January 25, 2013 16:54
Show Gist options
  • Save dangra/4636013 to your computer and use it in GitHub Desktop.
Save dangra/4636013 to your computer and use it in GitHub Desktop.
# GistID: 4636013
def grpkey():
idx = 0
def _key(e):
print idx
if e:
idx += 1
return idx
return _key
kf = grpkey()
print kf(True)
# OUTPUT:
# Traceback (most recent call last):
# File "bb.py", line 15, in <module>
# print kf(True)
# File "bb.py", line 7, in _key
# print idx
# UnboundLocalError: local variable 'idx' referenced before assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment