TypeCast/meowr
TypeCast/Ushuaya
f1from functools import wrapsf1from functools import wraps
22
33
n4def cast(t):n4def cast(tyte):
5    def decorator(f):5    def _repeat(f):
6        @wraps(f)6        @wraps(f)
n7        def new_f(*args):n7        def inner(*args, **kwargs):
8            try:8            try:
n9                return t(f(*args))n9                return tyte(f(*args))
10            except BaseException:10            except BaseException:
11                return f(*args)11                return f(*args)
n12        return new_fn12        return inner
13    return decorator13    return _repeat
1414
tt15# @cast(int)
16# def fun(a, b):
17#     return a * 2 + b
18# print(fun(12, 34) * 2)
19# print(fun("12", "34") * 2)
20# print(fun(12.765, 34.654) * 2)
21 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op