f | def sizer(cls): | f | def sizer(cls): |
| | | |
n | def size_method(self): | n | def get_size(self): |
| if hasattr(self, '_size'): | | if hasattr(self, '_custom_size'): |
| return self._size | | return self._custom_size |
| if hasattr(self, '__len__'): | | if hasattr(self, '__len__'): |
| return len(self) | | return len(self) |
n | if hasattr(self, '__abs__'): | n | elif hasattr(self, '__abs__'): |
| return abs(self) | | return abs(self) |
n | | n | else: |
| return 0 | | return 0 |
| | | |
n | def size_setter(self, value): | n | def set_size(self, val): |
| self._size = value | | self._custom_size = val |
| | | |
t | def size_deleter(self): | t | def del_size(self): |
| if hasattr(self, '_size'): | | if hasattr(self, '_custom_size'): |
| del self._size | | del self._custom_size |
| cls.size = property(size_method, size_setter, size_deleter) | | cls.size = property(get_size, set_size, del_size) |
| return cls | | return cls |