Advertisement
Kamend1

Logger exercise - works in Judge

Mar 20th, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. def logged(function):
  2.  
  3.     def wrapper(*args):
  4.         result = function(*args)
  5.         function_name_str = str(function.__name__)
  6.         function_args = ", ".join(map(str, args))
  7.         log_result = "you called " + function_name_str + "(" + function_args + ")" + '\n' + "it returned " + str(result)
  8.         return log_result
  9.  
  10.     return wrapper
  11.  
  12. @logged
  13. def func(*args):
  14.     return 3 + len(args)
  15. print(func(4, 4, 4))
  16.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement