micropython

tests/attributes_instance_assignment_on_self.py

485:bb3d52ea8226
2012-02-27 Paul Boddie Added general attribute usage recording for attribute assignments on self, even though specific attribute usage is also recorded. This prevents usage from being inadvertently incomplete. Added tests demonstrating the contribution of attribute assignments to usage observations.
     1 #!/usr/bin/env python     2      3 class C:     4     def __init__(self, x):     5         self.x = x     6         self.z = None     7      8     def f(self, a):     9         if self.z:    10             pass    11         self.x = a    12     13 class D:    14     def __init__(self, y):    15         self.y = y    16         self.z = None    17     18 c = C(1)    19 d = D(2)    20 c.f(3)    21 result_3 = c.x    22     23 # vim: tabstop=4 expandtab shiftwidth=4