Last active
June 26, 2022 19:52
-
-
Save DougAF/86243b8feab3330bf4c69202ccda29a1 to your computer and use it in GitHub Desktop.
Tracing Decorator for Medium
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 functools | |
def tracefunc(func): | |
"""Decorates a function to show its trace.""" | |
@functools.wraps(func) | |
def tracefunc_closure(*args, **kwargs): | |
"""The closure.""" | |
result = func(*args, **kwargs) | |
print(f"{func.__name__}(args={args}, kwargs={kwargs}) => {result}") | |
return result | |
return tracefunc_closure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment