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