1# test function args, keyword only with default value 2 3# a single arg with a default 4def f1(*, a=1): 5 print(a) 6f1() 7f1(a=2) 8 9# 1 arg default, 1 not 10def f2(*, a=1, b): 11 print(a, b) 12f2(b=2) 13f2(a=2, b=3) 14 15# 1 positional, 1 arg default, 1 not 16def f3(a, *, b=2, c): 17 print(a, b, c) 18f3(1, c=3) 19f3(1, b=3, c=4) 20f3(1, **{'c':3}) 21f3(1, **{'b':'3', 'c':4}) 22 23# many args, not all with defaults 24def f4(*, a=1, b, c=3, d, e=5, f): 25 print(a, b, c, d, e, f) 26f4(b=2, d=4, f=6) 27f4(a=11, b=2, d=4, f=6) 28f4(a=11, b=2, c=33, d=4, e=55, f=6) 29f4(f=6, e=55, d=4, c=33, b=2, a=11) 30 31# positional with default, then keyword only 32def f5(a, b=4, *c, d=8): 33 print(a, b, c, d) 34f5(1) 35f5(1, d=9) 36f5(1, b=44, d=9) 37