| Виноградов Владимир Игоревич, ОУ Севастополь FuncCount 7689 | Aleksey FuncCount 8091 | ||||
|---|---|---|---|---|---|
| f | 1 | from functools import wraps | f | 1 | from functools import wraps |
| 2 | 2 | ||||
| n | 3 | def counter(fn): | n | 3 | def counter(func): |
| 4 | c = 0 | 4 | count = 0 | ||
| 5 | 5 | ||||
| n | 6 | @wraps(fn) | n | 6 | @wraps(func) |
| 7 | def w(*a, **kw): | 7 | def wrapper(*args, **kwargs): | ||
| 8 | nonlocal c | 8 | nonlocal count | ||
| 9 | c += 1 | 9 | count += 1 | ||
| 10 | return fn(*a, **kw) | 10 | return func(*args, **kwargs) | ||
| 11 | 11 | ||||
| t | 12 | def cnt(): | t | 12 | def counter_method(): |
| 13 | return c | 13 | return count | ||
| 14 | w.counter = cnt | 14 | wrapper.counter = counter_method | ||
| 15 | return w | 15 | return wrapper | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||