Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
__call__ method
>>> class Counter:
... def __init__(self):
... self.value = 0
... def __call__(self):
... self.value += 1
... return self.value
...
>>> c = Counter()
>>> c()
1
>>> c()
2
>>> c()
3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.