f | def fix(n): | f | def fix(n): |
| | | |
n | def decorator(foo): | n | def dec(fun): |
| | | |
n | def newfoo(*args, **kwargs): | n | def newfun(*args, **kwargs): |
| args = [round(v, n) if isinstance(v, float) else v for v in args] | | pos_args = [round(_, n) if isinstance(_, float) else _ for _ in args] |
| kwargs = {k: round(v, n) if isinstance(v, float) else v for (k, v) in kwargs.items()} | | named_args = {key: round(value, n) if isinstance(value, float) else value for (key, value) in kwargs.items()} |
| res = foo(*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 |
t | return newfoo | t | return newfun |
| return decorator | | return dec |