TypeCast/valmat07
TypeCast/Aleksyav
f1from functools import wrapsf1from functools import wraps
22
33
n4def cast(func_type):n4def cast(t):
5    def _cast(func):5    def decorator(f):
6        @wraps(func)6        @wraps(f)
7        def wrapper(*args, **kwargs):7        def newfun(*args, **kwargs):
8            return func_type(func(*args, **kwargs))8            return t(f(*args, **kwargs))
9        return wrapper9        return newfun
10    return _cast10    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