def f(a, *, b): print(a, b) f(a=1, b=2)print("f(a=1, b=2) works even though a has no default value")try: f(3, 4)except TypeError: print("f(3, 4) raises an error because b is keyword-only") def g(x=1): print(x) g(5)print("g(5) succeeds passing x positionally even though it has a default")
Standard input is empty
1 2 f(a=1, b=2) works even though a has no default value f(3, 4) raises an error because b is keyword-only 5 g(5) succeeds passing x positionally even though it has a default
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!