Skip to content

Instantly share code, notes, and snippets.

@tritium21
Created February 21, 2019 06:47
Show Gist options
  • Select an option

  • Save tritium21/e38ff55c3e3b1138da04c90bad7a7e8f to your computer and use it in GitHub Desktop.

Select an option

Save tritium21/e38ff55c3e3b1138da04c90bad7a7e8f to your computer and use it in GitHub Desktop.
import functools
def debug(message="*** DEBUG"):
def wrapper(func):
@functools.wraps(func)
def inner(*p, **kw):
print(message)
return func(*p, **kw)
return inner
return wrapper
@debug("*** foo")
def foo(a, b):
return a + b
print(foo(1, 2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment