| Стрельников Алексей, 617 UniSize 13372 | Демихов Валентин, 611 группа UniSize 13607 | ||||
|---|---|---|---|---|---|
| f | 1 | def sizer(cls): | f | 1 | def sizer(cls): |
| 2 | 2 | ||||
| n | 3 | class Size: | n | 3 | class SizeDescriptor: |
| 4 | 4 | ||||
| t | 5 | def __get__(self, obj, cls): | t | 5 | def __get__(self, instance, cls): |
| 6 | if hasattr(obj, '__len__'): | 6 | if hasattr(instance, '__len__'): | ||
| 7 | return len(obj) | 7 | return len(instance) | ||
| 8 | elif hasattr(obj, '__abs__'): | 8 | elif hasattr(instance, '__abs__'): | ||
| 9 | return abs(obj) | 9 | return abs(instance) | ||
| 10 | else: | ||||
| 11 | return 0 | 10 | return 0 | ||
| 12 | cls.size = Size() | 11 | cls.size = SizeDescriptor() | ||
| 13 | return cls | 12 | return cls | ||
| Legends | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||