2 ms·
Python has a bit of a wart in that arguments can normally be passed as keyword or positional. Python3 also added the ability to pass keyword only args (the ones
by joshuamorton 8y ago
Python has a bit of a wart in that arguments can normally be passed as keyword or positional. Python3 also added the ability to pass keyword only args (the ones after the `* `), That is
def f(a, b):
return a+b
can be called as `f(1, 2)` or `f(b=2, a=1)`, although I'd look at you funny if you did the second.
Certain functions implemented in C also have positional only args, so the function of signature
weird(p_only, /, pos, kw=None, * , kw_only=None)
can be called in the following ways (1 is p_only, 2, is pos, 3 is kw, 4 is kw_only)
weird(1, 2, 3)
weird(1, 2, 3, kw_only=4)
weird(1, pos=2, kw=3)
weird(1, pos=2)
weird(1, 2, kw_only=4)
...
but not
weird(p_only=1, 2)
weird(1,2,3,4)
...