| Вадим Флягин, вольный слушатель FuncCount 8485 | action22k FuncCount 8409 | ||||
|---|---|---|---|---|---|
| f | 1 | from functools import wraps | f | 1 | from functools import wraps |
| 2 | 2 | ||||
| n | 3 | def counter(f): | n | 3 | def counter(func): |
| 4 | 4 | ||||
| t | 5 | @wraps(f) | t | 5 | @wraps(func) |
| 6 | def helper(*args, **kwargs): | 6 | def wrapper(*args, **kwargs): | ||
| 7 | helper.calls += 1 | 7 | wrapper.count += 1 | ||
| 8 | return f(*args, **kwargs) | 8 | return func(*args, **kwargs) | ||
| 9 | helper.calls = 0 | 9 | wrapper.count = 0 | ||
| 10 | helper.counter = lambda: helper.calls | 10 | wrapper.counter = lambda: wrapper.count | ||
| 11 | return helper | 11 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||