mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
bpo-36540: Improve doc of function definition regarding positional-only arguments (GH-25235)
This commit is contained in:
parent
b05440c52b
commit
58d72cab89
1 changed files with 8 additions and 2 deletions
|
|
@ -1215,19 +1215,25 @@ e.g.::
|
||||||
return penguin
|
return penguin
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
|
single: / (slash); function definition
|
||||||
single: * (asterisk); function definition
|
single: * (asterisk); function definition
|
||||||
single: **; function definition
|
single: **; function definition
|
||||||
|
|
||||||
Function call semantics are described in more detail in section :ref:`calls`. A
|
Function call semantics are described in more detail in section :ref:`calls`. A
|
||||||
function call always assigns values to all parameters mentioned in the parameter
|
function call always assigns values to all parameters mentioned in the parameter
|
||||||
list, either from position arguments, from keyword arguments, or from default
|
list, either from positional arguments, from keyword arguments, or from default
|
||||||
values. If the form "``*identifier``" is present, it is initialized to a tuple
|
values. If the form "``*identifier``" is present, it is initialized to a tuple
|
||||||
receiving any excess positional parameters, defaulting to the empty tuple.
|
receiving any excess positional parameters, defaulting to the empty tuple.
|
||||||
If the form "``**identifier``" is present, it is initialized to a new
|
If the form "``**identifier``" is present, it is initialized to a new
|
||||||
ordered mapping receiving any excess keyword arguments, defaulting to a
|
ordered mapping receiving any excess keyword arguments, defaulting to a
|
||||||
new empty mapping of the same type. Parameters after "``*``" or
|
new empty mapping of the same type. Parameters after "``*``" or
|
||||||
"``*identifier``" are keyword-only parameters and may only be passed
|
"``*identifier``" are keyword-only parameters and may only be passed
|
||||||
used keyword arguments.
|
by keyword arguments. Parameters before "``/``" are positional-only parameters
|
||||||
|
and may only be passed by positional arguments.
|
||||||
|
|
||||||
|
.. versionchanged:: 3.8
|
||||||
|
The ``/`` function parameter syntax may be used to indicate positional-only
|
||||||
|
parameters. See :pep:`570` for details.
|
||||||
|
|
||||||
.. index::
|
.. index::
|
||||||
pair: function; annotations
|
pair: function; annotations
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue