n | class Descr: | n | class Desc: |
| | | |
| def __get__(self, obj, cls): | | def __get__(self, obj, cls): |
n | if hasattr(obj, '_size'): | n | if hasattr(obj, '_value'): |
| return obj._size | | return obj._value |
| if hasattr(obj, '__len__'): | | elif hasattr(obj, '__len__'): |
| return len(obj) | | return len(obj) |
n | if hasattr(obj, '__abs__'): | n | elif hasattr(obj, '__abs__'): |
| return abs(obj) | | return abs(obj) |
n | | n | else: |
| return 0 | | return 0 |
| | | |
| def __set__(self, obj, val): | | def __set__(self, obj, val): |
n | obj._size = val | n | obj._value = val |
| | | |
| def __delete__(self, obj): | | def __delete__(self, obj): |
n | del obj._size | n | del obj._value |
| | | |
| def sizer(cls): | | def sizer(cls): |
t | cls.size = Descr() | t | cls.size = Desc() |
| return cls | | return cls |