Lichen

tests/assign_attr.py

934:2989aab1b4f7
7 months ago Paul Boddie Renamed the utf8string class to unicode, eliminating the unicode function. This means that the simple case of merely returning an object if it is already a Unicode object no longer occurs when using the unicode callable, but such behaviour might be better supported with more general customised instantiation functionality.
     1 class C:     2     def __init__(self, x):     3         self.x = x     4      5     def __str__(self):     6         return "C(%r)" % self.x     7      8     __repr__ = __str__     9     10 class D:    11     x = 1    12     13 def f():    14     return D    15     16 c = C(C(1)) # c.x.x = 1    17 print c     # C(C(1))    18 print c.x   # C(1)    19 print c.x.x # 1    20 c.x.x = 2    21 print c     # C(C(2))    22 print c.x   # C(2)    23 print c.x.x    24     25 print D.x   # 1    26 D.x = 2    27 print D.x   # 2    28 D.x = C(3)    29 print D.x   # C(3)    30 print D.x.x # 3    31 D.x.x = 4    32 print D.x.x # 4    33     34 f().x = 5    35 print D.x   # 5