Skip to content

Commit 3b1cf20

Browse files
authored
[3.9] bpo-36540: Improve doc of function definition regarding positional-only arguments (GH-25235) (GH-25259)
(cherry picked from commit 58d72ca) Co-authored-by: Saiyang Gou <[email protected]>
1 parent f91fc7a commit 3b1cf20

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,19 +587,25 @@ e.g.::
587587
return penguin
588588

589589
.. index::
590+
single: / (slash); function definition
590591
single: * (asterisk); function definition
591592
single: **; function definition
592593
593594
Function call semantics are described in more detail in section :ref:`calls`. A
594595
function call always assigns values to all parameters mentioned in the parameter
595-
list, either from position arguments, from keyword arguments, or from default
596+
list, either from positional arguments, from keyword arguments, or from default
596597
values. If the form "``*identifier``" is present, it is initialized to a tuple
597598
receiving any excess positional parameters, defaulting to the empty tuple.
598599
If the form "``**identifier``" is present, it is initialized to a new
599600
ordered mapping receiving any excess keyword arguments, defaulting to a
600601
new empty mapping of the same type. Parameters after "``*``" or
601602
"``*identifier``" are keyword-only parameters and may only be passed
602-
used keyword arguments.
603+
by keyword arguments. Parameters before "``/``" are positional-only parameters
604+
and may only be passed by positional arguments.
605+
606+
.. versionchanged:: 3.8
607+
The ``/`` function parameter syntax may be used to indicate positional-only
608+
parameters. See :pep:`570` for details.
603609

604610
.. index::
605611
pair: function; annotations

0 commit comments

Comments
 (0)