Created
August 16, 2012 17:00
-
-
Save tokibito/3371676 to your computer and use it in GitHub Desktop.
__call__ method
This file contains hidden or 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
>>> 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