f | def fix(n): | f | def fix(n): |
| | | |
n | def decorator(fun): | n | def dec(fun): |
| | | |
| def newfun(*args, **kwargs): | | def newfun(*args, **kwargs): |
n | args = [round(arg, n) if isinstance(arg, float) else arg for arg in args] | n | pos_args = [round(_, n) if isinstance(_, float) else _ for _ in args] |
| kwargs = {key: round(value, n) if isinstance(value, float) else value for (key, value) in kwargs.items()} | | named_args = {key: round(value, n) if isinstance(value, float) else value for (key, value) in kwargs.items()} |
| res = fun(*args, **kwargs) | | res = fun(*pos_args, **named_args) |
| return round(res, n) if isinstance(res, float) else res | | return round(res, n) if isinstance(res, float) else res |
| return newfun | | return newfun |
t | return decorator | t | return dec |