Created
November 27, 2017 08:16
-
-
Save dansondergaard/10454bdb08982e9c1d206edb05c26dbf 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
def call_count(func): | |
def wrapper(*args, **kwargs): | |
wrapper.call_count += 1 | |
return func(*args, **kwargs) | |
wrapper.call_count = 0 | |
return wrapper | |
@call_count | |
def foo(x): | |
return x + 1 | |
foo(1) | |
foo(2) | |
print(foo.call_count) | |
foo(3) | |
print(foo.call_count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment