f | def sizer(cls): | f | def sizer(cls): |
| | | |
| def get_size(self): | | def get_size(self): |
n | if hasattr(self, '_size'): | n | 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 set_size(self, value): | n | def set_size(self, val): |
| self._size = value | | self._custom_size = val |
| | | |
| def del_size(self): | | def del_size(self): |
t | if hasattr(self, '_size'): | t | if hasattr(self, '_custom_size'): |
| del self._size | | del self._custom_size |
| cls.size = property(get_size, set_size, del_size) | | cls.size = property(get_size, set_size, del_size) |
| return cls | | return cls |