| Тулинова Олеся Вадимовна, 442 группа FuncCount 9021 | Aleksey FuncCount 8091 | ||||
|---|---|---|---|---|---|
| t | 1 | from functools import wraps | t | 1 | from functools import wraps |
| 2 | 2 | ||||
| 3 | def counter(func): | 3 | def counter(func): | ||
| 4 | count = 0 | 4 | count = 0 | ||
| 5 | 5 | ||||
| 6 | @wraps(func) | 6 | @wraps(func) | ||
| 7 | def wrapper(*args, **kwargs): | 7 | def wrapper(*args, **kwargs): | ||
| 8 | nonlocal count | 8 | nonlocal count | ||
| 9 | count += 1 | 9 | count += 1 | ||
| 10 | return func(*args, **kwargs) | 10 | return func(*args, **kwargs) | ||
| 11 | 11 | ||||
| 12 | def counter_method(): | 12 | def counter_method(): | ||
| 13 | return count | 13 | return count | ||
| 14 | wrapper.counter = counter_method | 14 | wrapper.counter = counter_method | ||
| 15 | return wrapper | 15 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||