UniSize/kunsar
UniSize/Ushuaya
n1class SizeDescriptor:n1class Dsc:
2    def __get__(self, instance, owner):2 
3    def __get__(self, obj, cls):
4        #print(f"Get from {cls}:{obj}")
3        try:5        try:
n4            return len(instance)n6            return len(obj)
5        except BaseException:7        except BaseException:
6            try:8            try:
n7                return abs(instance)n9                return abs(obj)
8            except BaseException:10            except BaseException:
9                return 011                return 0
1012
1113
12def sizer(cls):14def sizer(cls):
n13    cls.size = SizeDescriptor()n15    cls.size = Dsc()
14    return cls16    return cls
1517
nn18# @sizer
19# class S(str):
20#     pass
1621
n17# if __name__ == "__main__":n
18#     @sizer22# @sizer
19#     class S(str):
20#         pass
21#
22#
23#     @sizer
24#     class N(complex):23# class N(complex):
25#         pass24#     pass
26#
27#
28#     @sizer
29#     class E(Exception):
30#         pass
31#
32#
33#     for obj in S("QWER"), N(3 + 4j), E("Exceptions know no lengths!"):
34#         print(obj, obj.size)
3525
tt26# @sizer
27# class E(Exception):
28#     pass
29 
30# for obj in S("QWER"), N(3+4j), E("Exceptions know no lengths!"):
31#     print(obj, obj.size)
32 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op