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