1class MemnickMemory:
2 frazes = {}
3
4
5def memnick(*functions):
6 frazes = MemnickMemory.frazes
7 def decorator(func):
8 def wrapper(*args, **kwargs):
9 if not functions:
10 fraze = func(*args, **kwargs)
11 name = fraze.split(', ')[0]
12 frazes[name] = frazes.get(name, []) + [(fraze, func.__name__.replace('_', ' ').title())]
13 return func(*args, **kwargs)
14 wrapper.__name__ = func.__name__
15 return wrapper
16 if functions:
17 result = []
18 for f in functions:
19 for fraze, name in frazes.get(f.__name__.replace('_', ' ').title(), []):
20 result.append(f"С гласа на {name}: {fraze}") if f"С гласа на {name}: {fraze}" not in result else None
21 return result
22 return decorator
.....
----------------------------------------------------------------------
Ran 5 tests in 0.001s
OK
| f | 1 | class MemnickMemory: | f | 1 | class MemnickMemory: |
| 2 | frazes = {} | 2 | frazes = {} | ||
| 3 | 3 | ||||
| 4 | 4 | ||||
| 5 | def memnick(*functions): | 5 | def memnick(*functions): | ||
| 6 | frazes = MemnickMemory.frazes | 6 | frazes = MemnickMemory.frazes | ||
| 7 | def decorator(func): | 7 | def decorator(func): | ||
| 8 | def wrapper(*args, **kwargs): | 8 | def wrapper(*args, **kwargs): | ||
| 9 | if not functions: | 9 | if not functions: | ||
| t | t | 10 | fraze = func(*args, **kwargs) | ||
| 10 | name, fraze = func().split(', ')[0], func() | 11 | name = fraze.split(', ')[0] | ||
| 11 | frazes[name] = frazes.get(name, []) + [(fraze, func.__name__.replace('_', ' ').title())] | 12 | frazes[name] = frazes.get(name, []) + [(fraze, func.__name__.replace('_', ' ').title())] | ||
| 12 | return func(*args, **kwargs) | 13 | return func(*args, **kwargs) | ||
| 13 | wrapper.__name__ = func.__name__ | 14 | wrapper.__name__ = func.__name__ | ||
| 14 | return wrapper | 15 | return wrapper | ||
| 15 | if functions: | 16 | if functions: | ||
| 16 | result = [] | 17 | result = [] | ||
| 17 | for f in functions: | 18 | for f in functions: | ||
| 18 | for fraze, name in frazes.get(f.__name__.replace('_', ' ').title(), []): | 19 | for fraze, name in frazes.get(f.__name__.replace('_', ' ').title(), []): | ||
| 19 | result.append(f"С гласа на {name}: {fraze}") if f"С гласа на {name}: {fraze}" not in result else None | 20 | result.append(f"С гласа на {name}: {fraze}") if f"С гласа на {name}: {fraze}" not in result else None | ||
| 20 | return result | 21 | return result | ||
| 21 | return decorator | 22 | return decorator | ||
| 22 | 23 |
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||
15.03.2026 13:07
15.03.2026 13:07