| Nikita_luk FuncCount 8166 | Летуновский Кирилл Ефимович 515 FuncCount 8433 | ||||
|---|---|---|---|---|---|
| f | 1 | from functools import wraps | f | 1 | from functools import wraps |
| 2 | 2 | ||||
| 3 | def counter(func): | 3 | def counter(func): | ||
| n | 4 | func.count = 0 | n | 4 | func.call_count = 0 |
| 5 | 5 | ||||
| 6 | @wraps(func) | 6 | @wraps(func) | ||
| 7 | def wrapper(*args, **kwargs): | 7 | def wrapper(*args, **kwargs): | ||
| n | 8 | func.count += 1 | n | 8 | func.call_count += 1 |
| 9 | return func(*args, **kwargs) | 9 | return func(*args, **kwargs) | ||
| 10 | 10 | ||||
| t | 11 | def _counter(): | t | 11 | def counter_method(): |
| 12 | return func.count | 12 | return func.call_count | ||
| 13 | wrapper.counter = _counter | 13 | wrapper.counter = counter_method | ||
| 14 | return wrapper | 14 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||