TypeCast/SVasi1yev
TypeCast/olya.volodina
f1from functools import wrapsf1from functools import wraps
22
33
n4def cast(type_):n4def cast(type):
5    def decorator(f):5    def decorator(f):
6        @wraps(f)6        @wraps(f)
7        def wrapper(*args, **kwargs):7        def wrapper(*args, **kwargs):
n8            res = f(*args, **kwargs)n8            result = f(*args, **kwargs)
9            return type_(res)9            return type(result)
10        return wrapper10        return wrapper
11    return decorator11    return decorator
1212
1313
n14# @cast(int)n14# @cast(list)
15# def fun(a, b):15# def fun(a, b):
16#     return a * 2 + b16#     return a * 2 + b
t17# print(fun(12, 34) * 2)t
18# print(fun("12", "34") * 2)17# print(*fun("QW", "er"))
19# print(fun(12.765, 34.654) * 2)18# print(*fun(sorted("WDC"), sorted("rfv")))
19# print(fun.__name__)
2020
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op