Skip to content

Instantly share code, notes, and snippets.

@DougAF
Last active June 26, 2022 19:52
Show Gist options
  • Save DougAF/86243b8feab3330bf4c69202ccda29a1 to your computer and use it in GitHub Desktop.
Save DougAF/86243b8feab3330bf4c69202ccda29a1 to your computer and use it in GitHub Desktop.
Tracing Decorator for Medium
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