Created
October 22, 2013 22:47
-
-
Save skimbrel/7109522 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
In [13]: def counter_factory(): | |
....: count = 0 | |
....: def _counter(): | |
....: count += 1 | |
....: return _counter | |
....: | |
In [14]: f = counter_factory() | |
In [15]: f() | |
--------------------------------------------------------------------------- | |
UnboundLocalError Traceback (most recent call last) | |
<ipython-input-15-0ec059b9bfe1> in <module>() | |
----> 1 f() | |
<ipython-input-13-e9a70e60b268> in _counter() | |
2 count = 0 | |
3 def _counter(): | |
----> 4 count += 1 | |
5 return _counter | |
UnboundLocalError: local variable 'count' referenced before assignment |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment