f | import sys | f | import sys |
| | | |
n | class SizeD: | n | class SizeDescriptor: |
| | | |
| def __init__(self): | | def __init__(self): |
n | self._size = None | n | self._custom_value = None |
| | | |
n | def __get__(self, obj, cls): | n | def __get__(self, instance, owner): |
| if self._size is not None: | | if self._custom_value is not None: |
| return self._size | | return self._custom_value |
| if hasattr(obj, '__len__'): | | if hasattr(instance, '__len__'): |
| return len(obj) | | return len(instance) |
| if hasattr(obj, '__abs__'): | | if hasattr(instance, '__abs__'): |
| return abs(obj) | | return abs(instance) |
| return 0 | | return 0 |
| | | |
n | def __set__(self, obj, value): | n | def __set__(self, instance, new_value): |
| self._size = value | | self._custom_value = new_value |
| | | |
n | def __delete__(self, obj): | n | def __delete__(self, instance): |
| self._size = None | | self._custom_value = None |
| | | |
| def sizer(cls): | | def sizer(cls): |
t | cls.size = SizeD() | t | cls.size = SizeDescriptor() |
| return cls | | return cls |
| exec(sys.stdin.read()) | | exec(sys.stdin.read()) |