micropython

tests/attribute_usage_specific.py

519:814bd122d84d
2012-06-04 Paul Boddie Updated the documentation to reflect class attribute assignment policies. Added tests to demonstrate class attribute rebinding.
     1 #!/usr/bin/env python     2      3 class A:     4     def f(self, x):     5         return 0     6     def g(self, y):     7         return 2     8      9 class B:    10     def g(self, z):    11         return 4    12     13 def f(x, y):            # x : A, B    14     result = x.g(1)    15     while y:            # x : A only    16         y = x.f(1)    17     return result    18     19 a = A()    20 b = B()    21 result_2 = f(a, 1)    22     23 # vim: tabstop=4 expandtab shiftwidth=4