Basic usage
Input
(lambda f: (f(2, 3), f.calls))(make_adder())
Output
(5, [((2, 3), {})])
make_adder() returns an 'add' function decorated with @log_calls. Calling it with (2,3) returns 5 and records the call as ((2, 3), {}).
Full lesson preview
Create a decorator that records every call made to a function and preserves the function's behavior and metadata.
Problem statement
Task
Examples
Input
(lambda f: (f(2, 3), f.calls))(make_adder())
Output
(5, [((2, 3), {})])
make_adder() returns an 'add' function decorated with @log_calls. Calling it with (2,3) returns 5 and records the call as ((2, 3), {}).
Input format
Output format
Constraints
Samples
Input
(lambda f: (f(), f.calls))(make_greeter())
Output
('Hello, World!', [((), {})])
make_greeter() returns a function with a default parameter. Calling it without args returns 'Hello, World!' and logs the empty args tuple and empty kwargs dict.