2017-03-31 | Paul Boddie | file changeset files shortlog | Introduced a multiple outcome result which can be used to provide a choice of return values to supply the initialiser and alias details. |
paul@557 | 1 | class C: |
paul@557 | 2 | def f(self, x, y, z): |
paul@557 | 3 | return z |
paul@557 | 4 | |
paul@557 | 5 | class D: |
paul@557 | 6 | def f(self, a, b, c): |
paul@557 | 7 | return c |
paul@557 | 8 | |
paul@557 | 9 | def xyz(obj): |
paul@557 | 10 | return obj.f(1, 2, z=3) |
paul@557 | 11 | |
paul@557 | 12 | def abc(obj): |
paul@557 | 13 | return obj.f(4, 5, c=6) |
paul@557 | 14 | |
paul@557 | 15 | c = C() |
paul@557 | 16 | d = D() |
paul@557 | 17 | |
paul@557 | 18 | print xyz(c) # 3 |
paul@557 | 19 | print abc(d) # 6 |
paul@557 | 20 | |
paul@557 | 21 | try: |
paul@557 | 22 | print xyz(d) # should raise an exception |
paul@557 | 23 | except TypeError: |
paul@557 | 24 | print "xyz(d): argument cannot be used" |