September 2026
1051 pages
35h 4m
English
In addition to keyword-only parameters, you can also mark positional-only parameters. This refers to function parameters that may only be passed as a positional argument and not as a keyword argument.
Positional-only parameters must be placed at the very beginning of the parameter list of a function and are separated from the remaining parameters by a forward slash (/):
>>> def f(a, b, /, c, d):... print(a, b, c, d)...>>> f(1, b=2, c=3, d=4)Traceback (most recent call last): File "<python-input-1>", line 1, in <module> f(1, b=2, c=3, d=4) ~^^^^^^^^^^^^^^^^^^TypeError: f() got some positional-only arguments passed as keyword arguments: 'b'>>> f(1, 2, c=3, d=4)1 2 3 4
The syntax for defining positional-only ...
Read now
Unlock full access