Created
January 25, 2013 16:54
-
-
Save dangra/4636013 to your computer and use it in GitHub Desktop.
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
# 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