| Котляревская Анна Евгеньевна 321 FuncCount 7612 | volandlm FuncCount 7606 | ||||
|---|---|---|---|---|---|
| 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 | k = 0 | 4 | count = 0 | ||
| 5 | 5 | ||||
| t | 6 | @wraps(f) | t | 6 | @wraps(func) |
| 7 | def wrapper(*args, **kwds): | 7 | def wrapper(*args, **kwargs): | ||
| 8 | nonlocal k | 8 | nonlocal count | ||
| 9 | k += 1 | 9 | count += 1 | ||
| 10 | return f(*args, **kwds) | 10 | return func(*args, **kwargs) | ||
| 11 | wrapper.counter = lambda: k | 11 | wrapper.counter = lambda: count | ||
| 12 | return wrapper | 12 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||