TypeCast/dianarudenko
TypeCast/Aleksyav
f1from functools import wrapsf1from functools import wraps
22
33
n4def cast(tp):n4def cast(t):
5    def decorator(f):5    def decorator(f):
6        @wraps(f)6        @wraps(f)
n7        def new_f(*args, **kwargs):n7        def newfun(*args, **kwargs):
8            return tp(f(*args, **kwargs))8            return t(f(*args, **kwargs))
9        return new_f9        return newfun
10    return decorator10    return decorator
1111
t12# @cast(int)t
13# def fun(a, b):
14#     return a * 2 + b
15# print(fun(12, 34) * 2)
16# print(fun("12", "34") * 2)
17# print(fun(12.765, 34.654) * 2)
18 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op