f | def fix(n): | f | def fix(n): |
| | | |
n | def dec(fun): | n | def decorator(func): |
| | | |
n | def newfun(*args, **kw): | n | def new_func(*args, **kwargs): |
| args = list(args) | | args = list(args) |
| for i in range(len(args)): | | for i in range(len(args)): |
| if isinstance(args[i], float): | | if isinstance(args[i], float): |
| args[i] = round(args[i], n) | | args[i] = round(args[i], n) |
t | for i in kw: | t | for var in kwargs: |
| if isinstance(kw[i], float): | | if isinstance(kwargs[var], float): |
| kw[i] = round(kw[i], n) | | kwargs[var] = round(kwargs[var], n) |
| a = fun(*args, **kw) | | ans = func(*args, **kwargs) |
| if isinstance(a, float): | | if isinstance(ans, float): |
| a = round(a, n) | | ans = round(ans, n) |
| return a | | return ans |
| return newfun | | return new_func |
| return dec | | return decorator |