Last active
February 1, 2020 22:43
-
-
Save edenau/15c72f0e92612379c7ba55101ad8e06b to your computer and use it in GitHub Desktop.
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
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