micropython

tests/subclass.py

530:0f9aa4c4d92c
2012-06-09 Paul Boddie Added an __iter__ method for strings.
     1 #!/usr/bin/env python     2      3 class A:     4     def __init__(self, x):     5         self.x = x     6      7     def a(self):     8         return self.x     9     10 class B(A):    11     def b(self):    12         return 2    13     14 class C(A, B):    15     def a(self):    16         return self.y    17     18     def b(self):    19         return self.a()    20     21     def c(self):    22         return A.a(self)    23     24     def __init__(self, x, y):    25         self.x = x    26         self.y = y    27     28 class D:    29     def __init__(self, y):    30         self.z = y    31     32     def a(self):    33         return self.z    34     35 class E(C, D):    36     pass    37     38 class F(A, D):    39     pass    40     41 a = A(1)    42 b = B(1)    43 c = C(1, 2)    44 d = D(3)    45 e = E(3, 4)    46 f = F(5)    47     48 result1_1 = a.a()    49 result1_2 = b.b()    50 result2_2 = c.a()    51 result3_2 = c.b()    52 result2_1 = c.c()    53 result_3 = d.a()    54 result_4 = e.a()    55 result_5 = f.a()    56     57 # vim: tabstop=4 expandtab shiftwidth=4