Created
September 2, 2020 09:26
-
-
Save ycui1/d265b4eb9e0e8e083b28fb1fab474418 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
>>> import time | |
... from functools import wraps | |
... | |
... def logging_time(func): | |
... """Decorator that logs time""" | |
... @wraps(func) | |
... def logger(*args, **kwargs): | |
... """Function that logs time""" | |
... start = time.time() | |
... func(*args, **kwargs) | |
... print(f"Calling {func.__name__}: {time.time() - start:.5f}") | |
... | |
... return logger | |
... | |
... | |
... @logging_time | |
... def say_hello(whom): | |
... """Greet someone""" | |
... print(f"Hello, {whom}!") | |
... | |
... print(say_hello.__doc__) | |
... | |
Greet someone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment