n | class Dsc: | n | class SizerClass: |
| | | |
| def __init__(self): | | def __init__(self): |
n | self.size = None | n | self._value = 0 |
| | | |
| def __get__(self, obj, cls): | | def __get__(self, obj, cls): |
n | if self.size: | n | if self._value: |
| return self.size | | return self._value |
| try: | | try: |
| return len(obj) | | return len(obj) |
| except: | | except: |
| try: | | try: |
| return abs(obj) | | return abs(obj) |
| except: | | except: |
| return 0 | | return 0 |
| | | |
| def __set__(self, obj, val): | | def __set__(self, obj, val): |
n | self.size = val | n | self._value = val |
| | | |
| def __delete__(self, obj): | | def __delete__(self, obj): |
n | self.size = None | n | self._value = None |
| | | |
| def sizer(cls): | | def sizer(cls): |
t | cls.size = Dsc() | t | cls.size = SizerClass() |
| return cls | | return cls |