Skip to content

Instantly share code, notes, and snippets.

@Gohan
Last active January 21, 2016 05:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gohan/46be9ed0f2d01f8df4d3 to your computer and use it in GitHub Desktop.
Save Gohan/46be9ed0f2d01f8df4d3 to your computer and use it in GitHub Desktop.
def new_counter(c):
counter = itertools.count(c)
def f():
return counter.next()
return f;
def new_counter(c):
counter = itertools.count(c)
return lambda x=0:counter.next()
class new_counter(itertools.count):
def __init__(self, *args, **kwargs):
super(new_counter, self).__init__(*args, **kwargs)
def __call__(self):
return self.next()
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment