Skip to content

Instantly share code, notes, and snippets.

@skimbrel
Created October 22, 2013 23:00
Show Gist options
  • Save skimbrel/7109661 to your computer and use it in GitHub Desktop.
Save skimbrel/7109661 to your computer and use it in GitHub Desktop.
In [31]: def create_counter():
....: def _counter():
....: global count
....: count += 1
....: return count
....: return _counter
....:
In [32]: f = create_counter()
In [33]: f()
Out[33]: 1
In [34]: g = create_counter()
In [35]: g()
Out[35]: 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment