Objective
Create a Python program with your first decorator: a function that wraps another one to add behaviour to it.
Instructions
- Define
def log_calls(function). Inside, definewrapper(*args, **kwargs), which showsCalling NAME with ARGS(usefunction.__name__and theargstuple), calls the original function and returns its result.log_callsreturnswrapper. - Define
add(a, b), which returnsa + b, and decorate it with@log_calls. - Read two integers (one per line), call
addand showResult: R.
3
4
Calling add with (3, 4)
Result: 7
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise