[Python-checkins] [3.9] bpo-36540: Improve doc of function definition regarding positional-only arguments (GH-25235) (GH-25259)
pablogsal
webhook-mailer at python.org
Wed Apr 7 15:32:56 EDT 2021
https://github.com/python/cpython/commit/3b1cf202976d9590d5b453c47b883f2e7cd1a7a5
commit: 3b1cf202976d9590d5b453c47b883f2e7cd1a7a5
branch: 3.9
author: Saiyang Gou <gousaiyang at 163.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2021-04-07T20:32:48+01:00
summary:
[3.9] bpo-36540: Improve doc of function definition regarding positional-only arguments (GH-25235) (GH-25259)
(cherry picked from commit 58d72cab89cf9652acc0bf0007aa20b2bcc98499)
Co-authored-by: Saiyang Gou <gousaiyang at 163.com>
files:
M Doc/reference/compound_stmts.rst
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index 7e666351b1b31..f7eca2aa8472b 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -587,19 +587,25 @@ e.g.::
return penguin
.. index::
+ single: / (slash); function definition
single: * (asterisk); function definition
single: **; function definition
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
-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
receiving any excess positional parameters, defaulting to the empty tuple.
If the form "``**identifier``" is present, it is initialized to a new
ordered mapping receiving any excess keyword arguments, defaulting to a
new empty mapping of the same type. Parameters after "``*``" or
"``*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::
pair: function; annotations
More information about the Python-checkins
mailing list