Skip to content

Instantly share code, notes, and snippets.

@curtisforrester
Last active June 16, 2016 12:04
Show Gist options
  • Save curtisforrester/3ee602a14bce2b3dc90604d20cfe6d3f to your computer and use it in GitHub Desktop.
Save curtisforrester/3ee602a14bce2b3dc90604d20cfe6d3f to your computer and use it in GitHub Desktop.
Python decorator to print function arguments
from functools import wraps
def print_args():
def decorator(func):
@wraps(func)
def func_wrapper(*args, **kwargs):
print('args: [%r], kwargs: [%r]' % (args, kwargs))
return func(*args, **kwargs)
return func_wrapper
return decorator
@print_args()
def foo(parm1, parm2, parm3='third'):
pass
foo('first', parm2='second')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment