| Барлыбай Мади, 311/312 группа FuncCount 8172 | Mikhailenko Alexandr Sergeevich 316 FuncCount 7539 | ||||
|---|---|---|---|---|---|
| t | 1 | from functools import wraps | t | 1 | from functools import wraps |
| 2 | 2 | ||||
| 3 | def counter(func): | 3 | def counter(func): | ||
| 4 | calls = 0 | 4 | calls = 0 | ||
| 5 | 5 | ||||
| 6 | @wraps(func) | 6 | @wraps(func) | ||
| 7 | def wrapper(*args, **kwargs): | 7 | def wrapper(*args, **kwargs): | ||
| 8 | nonlocal calls | 8 | nonlocal calls | ||
| 9 | calls += 1 | 9 | calls += 1 | ||
| 10 | return func(*args, **kwargs) | 10 | return func(*args, **kwargs) | ||
| 11 | 11 | ||||
| 12 | def get_calls(): | 12 | def get_calls(): | ||
| 13 | return calls | 13 | return calls | ||
| 14 | wrapper.counter = get_calls | 14 | wrapper.counter = get_calls | ||
| 15 | return wrapper | 15 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||