Skip to content

Instantly share code, notes, and snippets.

@edenau
Last active February 1, 2020 22:43
Show Gist options
  • Save edenau/15c72f0e92612379c7ba55101ad8e06b to your computer and use it in GitHub Desktop.
Save edenau/15c72f0e92612379c7ba55101ad8e06b to your computer and use it in GitHub Desktop.
def trace(func):
def print_in(*args, **kwargs):
print('Executing function', func.__name__)
return func(*args, **kwargs)
return print_in
@trace
def calc(a,b):
print(f'a+b is {a+b}, a-b is {a-b}.')
calc(1,2)
# Executing function calc
# a+b is 3, a-b is -1.
@trace
def add_all(*args):
print(reduce(lambda a,b:a+b, args))
a = add_all(1,2,3,4,5)
# Executing function add_all
# 15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment