1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tests/keyword_args.py Wed Feb 08 16:20:27 2017 +0100
1.3 @@ -0,0 +1,24 @@
1.4 +class C:
1.5 + def f(self, x, y, z):
1.6 + return z
1.7 +
1.8 +class D:
1.9 + def f(self, a, b, c):
1.10 + return c
1.11 +
1.12 +def xyz(obj):
1.13 + return obj.f(1, 2, z=3)
1.14 +
1.15 +def abc(obj):
1.16 + return obj.f(4, 5, c=6)
1.17 +
1.18 +c = C()
1.19 +d = D()
1.20 +
1.21 +print xyz(c) # 3
1.22 +print abc(d) # 6
1.23 +
1.24 +try:
1.25 + print xyz(d) # should raise an exception
1.26 +except TypeError:
1.27 + print "xyz(d): argument cannot be used"