Write a decorator which wraps functions to log function arguments and the return value on each call. Provide support for both positional and named arguments (your wrapper function should take both *args and **kwargs and print them both): >>> @logged def func(*args): return 3 + len(args) >>> func(4, 4, 4) you called func(4, 4, 4) it returned 6

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter12: Adding Functionality To Your Classes
Section12.5: Virtual Functions
Problem 3E
icon
Related questions
Question
100%

DO IN PYTHON

Write a decorator which wraps functions to log function arguments and the return value on each call.
Provide support for both positional and named arguments (your wrapper function should take both
*args and **kwargs and print them both):
>>> @logged
def func(*args):
return 3 + len(args)
..
>>> func(4, 4, 4)
you called func(4, 4, 4)
it returned 6
6.
Transcribed Image Text:Write a decorator which wraps functions to log function arguments and the return value on each call. Provide support for both positional and named arguments (your wrapper function should take both *args and **kwargs and print them both): >>> @logged def func(*args): return 3 + len(args) .. >>> func(4, 4, 4) you called func(4, 4, 4) it returned 6 6.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning