Implement a class-based decorator that validates argument types and logs successful calls.
Constraints
Example
>>> @validate_and_log(int)
... def double(x):
... return x * 2
>>> double(5)
10
>>> validate_and_log.call_log
[(5, 10)]
>>> double.__name__
'double'
>>> try:
... double("5")
... except TypeError as e:
... print(e)
Argument must be of type int
>>> @validate_and_log(float)
... def float_function(x):
... return x
>>> float_function(2.5)
2.5
>>> [list(item) for item in validate_and_log.call_log]
[[5, 10], [2.5, 2.5]]
Recent Submissions
No submissions yet — hit Run Tests to try!
Hints