f | def fix(n): | f | def fix(n): |
| | | |
n | def decorator(fun): | n | def decorator(func): |
| | | |
n | def newfun(*args, **kwargs): | n | def _decoracor(*args, **kwargs): |
| newargs = [] | | new_args = [] |
| for item in args: | | for arg in args: |
| if type(item) == float: | | if type(arg) == float: |
| newargs.append(round(item, n)) | | new_args.append(round(arg, n)) |
| else: | | else: |
n | newargs.append(item) | n | new_args.append(arg) |
| newkwargs = {} | | new_kwargs = {} |
| for (key, item) in kwargs.items(): | | for (k, v) in kwargs.items(): |
| if type(item) == float: | | if type(v) == float: |
| newkwargs[key] = round(item, n) | | new_kwargs[k] = round(v, n) |
| else: | | else: |
n | newkwargs[key] = item | n | new_kwargs[k] = v |
| result = fun(*newargs, **newkwargs) | | res = func(*tuple(new_args), **new_kwargs) |
| if type(result) == float: | | if type(res) == float: |
| return round(result, n) | | return round(res, n) |
| else: | | else: |
t | return result | t | return res |
| return newfun | | return _decoracor |
| return decorator | | return decorator |