We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Here's one that blew my mind (and my co-workers):
def incrementer(): i = 0 def increment(): i = i + 1 return i return increment
Looks OK. Let's try it.
>>> i = incrementer() >>> i() --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-3-fa1b63ea38ec> in <module>() ----> 1 i() <ipython-input-1-482b5332e967> in increment() 2 i = 0 3 def increment(): ----> 4 i = i + 1 5 return i 6 return increment UnboundLocalError: local variable 'i' referenced before assignment
Fuck, even JavaScript got this one right!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Here's one that blew my mind (and my co-workers):
Looks OK. Let's try it.
>>> i = incrementer() >>> i() --------------------------------------------------------------------------- UnboundLocalError Traceback (most recent call last) <ipython-input-3-fa1b63ea38ec> in <module>() ----> 1 i() <ipython-input-1-482b5332e967> in increment() 2 i = 0 3 def increment(): ----> 4 i = i + 1 5 return i 6 return increment UnboundLocalError: local variable 'i' referenced before assignment
Fuck, even JavaScript got this one right!
The text was updated successfully, but these errors were encountered: