Бельницкая Елизавета Алексеевна 321 UniSize 13398 | Владимир Александров, не из МГУ UniSize 13397 | ||||
---|---|---|---|---|---|
n | 1 | class Sizer: | n | 1 | class Descr: |
2 | 2 | ||||
3 | def __get__(self, obj, cls): | 3 | def __get__(self, obj, cls): | ||
4 | if hasattr(obj, '__len__'): | 4 | if hasattr(obj, '__len__'): | ||
5 | return len(obj) | 5 | return len(obj) | ||
6 | elif hasattr(obj, '__abs__'): | 6 | elif hasattr(obj, '__abs__'): | ||
7 | return abs(obj) | 7 | return abs(obj) | ||
8 | return 0 | 8 | return 0 | ||
9 | 9 | ||||
10 | def sizer(cls): | 10 | def sizer(cls): | ||
t | 11 | cls.size = Sizer() | t | 11 | cls.size = Descr() |
12 | return cls | 12 | return cls |
Legends | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
|