f | def sizer(cls): | f | def sizer(cls): |
| | | |
n | def size_getter(self): | n | def get_size(self): |
| if hasattr(self, '_custom_size'): | | if hasattr(self, '_size'): |
| return self._custom_size | | return self._size |
| try: | | else: |
| return len(self) | | |
| except TypeError: | | |
| try: | | try: |
n | return abs(self) | n | return len(self) |
| except TypeError: | | except TypeError: |
n | | n | try: |
| | | return abs(self) |
| | | except TypeError: |
| return 0 | | return 0 |
| | | |
n | def size_setter(self, value): | n | def set_size(self, value): |
| self._custom_size = value | | self._size = value |
| | | |
t | def size_deleter(self): | t | def del_size(self): |
| if hasattr(self, '_custom_size'): | | if hasattr(self, '_size'): |
| del self._custom_size | | del self._size |
| setattr(cls, 'size', property(size_getter, size_setter, size_deleter | | setattr(cls, 'size', property(get_size, set_size, del_size)) |
| )) | | |
| return cls | | return cls |