Skip to content

Commit 4554ab4

Browse files
authored
[3.8] bpo-36540: Improve doc of function definition regarding positional-only arguments (GH-25235) (GH-25260)
(cherry picked from commit 58d72ca) Co-authored-by: Saiyang Gou <gousaiyang@163.com>
1 parent 9f57873 commit 4554ab4

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
@@ -582,19 +582,25 @@ e.g.::
582582
return penguin
583583

584584
.. index::
585+
single: / (slash); function definition
585586
single: * (asterisk); function definition
586587
single: **; function definition
587588
588589
Function call semantics are described in more detail in section :ref:`calls`. A
589590
function call always assigns values to all parameters mentioned in the parameter
590-
list, either from position arguments, from keyword arguments, or from default
591+
list, either from positional arguments, from keyword arguments, or from default
591592
values. If the form "``*identifier``" is present, it is initialized to a tuple
592593
receiving any excess positional parameters, defaulting to the empty tuple.
593594
If the form "``**identifier``" is present, it is initialized to a new
594595
ordered mapping receiving any excess keyword arguments, defaulting to a
595596
new empty mapping of the same type. Parameters after "``*``" or
596597
"``*identifier``" are keyword-only parameters and may only be passed
597-
used keyword arguments.
598+
by keyword arguments. Parameters before "``/``" are positional-only parameters
599+
and may only be passed by positional arguments.
600+
601+
.. versionchanged:: 3.8
602+
The ``/`` function parameter syntax may be used to indicate positional-only
603+
parameters. See :pep:`570` for details.
598604

599605
.. index::
600606
pair: function; annotations

0 commit comments

Comments
 (0)