| TypeCast/FrBrGeorge | TypeCast/MVPakaGuru | ||||
|---|---|---|---|---|---|
| n | 1 | #!/usr/bin/env python3 | n | ||
| 2 | ''' | ||||
| 3 | ''' | ||||
| 4 | from functools import wraps | 1 | from functools import wraps | ||
| 5 | 2 | ||||
| 6 | 3 | ||||
| t | 7 | def cast(typ): | t | 4 | def cast(out_type): |
| 8 | def _cast(fun): | 5 | def decorator(f): | ||
| 9 | @wraps(fun) | 6 | @wraps(f) | ||
| 10 | def _fun(*a, **k): | 7 | def wr(*args, **kwargs): | ||
| 11 | res = fun(*a, **k) | 8 | res = f(*args, **kwargs) | ||
| 12 | return typ(res) | 9 | return out_type(res) | ||
| 13 | return _fun | 10 | return wr | ||
| 14 | return _cast | 11 | return decorator | ||
| 15 | 12 | ||||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||