rmanzhos UniSize 13348 | Пономаренко Вячеслав Сергеевич, 525 группа UniSize 13292 | ||||
---|---|---|---|---|---|
n | 1 | class Size: | n | 1 | class Descr: |
2 | 2 | ||||
3 | def __get__(self, obj, cls): | 3 | def __get__(self, obj, cls): | ||
n | 4 | flds = dir(cls) | n | 4 | c_dir = dir(cls) |
5 | if '__len__' in flds: | 5 | if '__len__' in c_dir: | ||
6 | return len(obj) | 6 | return len(obj) | ||
n | 7 | elif '__abs__' in flds: | n | 7 | elif '__abs__' in c_dir: |
8 | return abs(obj) | 8 | return abs(obj) | ||
9 | else: | 9 | else: | ||
10 | return 0 | 10 | return 0 | ||
11 | 11 | ||||
12 | def sizer(cls): | 12 | def sizer(cls): | ||
t | 13 | cls.size = Size() | t | 13 | cls.size = Descr() |
14 | return cls | 14 | return cls |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|