Skip to content

gh-133438: Fix the use of the terms "argument" and "parameter" in the documentation #135160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Doc/c-api/arg.rst
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ inside nested parentheses. They are:

``$``
:c:func:`PyArg_ParseTupleAndKeywords` only:
Indicates that the remaining arguments in the Python argument list are
keyword-only. Currently, all keyword-only arguments must also be optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old wording is clearer here, "keyword-only" is a well-known term in Python.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keyword-only can be only parameters. Arguments are either positional or keyword. Argument is what we pass to the function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the same way, an argument can't be optional: if you omit it, it does not exist at all.

But the terms “optional” and “keyword-only” describe the possibilities you have, not a specific argument in a specific call.

Indicates that the remaining arguments in the Python argument list can be
supplied only by keyword. Currently, all such arguments must also be optional
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, “keyword” means something entirely different. IMO we need to use the full term.

Suggested change
supplied only by keyword. Currently, all such arguments must also be optional
supplied only as keyword arguments. Currently, all such arguments must also be optional

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is from the definition of the keyword-only parameter.

      * :dfn:`keyword-only`: specifies an argument that can be supplied only
        by keyword.  Keyword-only parameters can be defined by including a

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the context of PyArg_ParseTupleAndKeywords, 'keyword' means 'parameter name' rather than 'syntax keyword. So I think Serhiy's revision could be left as is, or changed to

Suggested change
supplied only by keyword. Currently, all such arguments must also be optional
supplied only by parameter name. Currently, all such arguments must also be optional

The keword-only definition is a bit circular. Perhaps by keyword should be changed to by parameter name to break the loop.

arguments, so ``|`` must always be specified before ``$`` in the format
string.

Expand Down Expand Up @@ -450,7 +450,7 @@ API Functions

.. c:function:: int PyArg_ParseTuple(PyObject *args, const char *format, ...)
Parse the parameters of a function that takes only positional parameters into
Parse the arguments of a function that takes only positional arguments into
local variables. Returns true on success; on failure, it returns false and
raises the appropriate exception.
Expand All @@ -463,8 +463,8 @@ API Functions
.. c:function:: int PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *kw, const char *format, char * const *keywords, ...)
Parse the parameters of a function that takes both positional and keyword
parameters into local variables.
Parse the arguments of a function that takes both positional and keyword
arguments into local variables.
The *keywords* argument is a ``NULL``-terminated array of keyword parameter
names specified as null-terminated ASCII or UTF-8 encoded C strings.
Empty names denote
Expand Down Expand Up @@ -506,7 +506,7 @@ API Functions
.. c:function:: int PyArg_Parse(PyObject *args, const char *format, ...)
Parse the parameter of a function that takes a single positional parameter
Parse the argument of a function that takes a single positional argument
into a local variable. Returns true on success; on failure, it returns
false and raises the appropriate exception.
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bound into a function.

.. c:function:: PyCodeObject* PyUnstable_Code_NewWithPosOnlyArgs(int argcount, int posonlyargcount, int kwonlyargcount, int nlocals, int stacksize, int flags, PyObject *code, PyObject *consts, PyObject *names, PyObject *varnames, PyObject *freevars, PyObject *cellvars, PyObject *filename, PyObject *name, PyObject *qualname, int firstlineno, PyObject *linetable, PyObject *exceptiontable)

Similar to :c:func:`PyUnstable_Code_New`, but with an extra "posonlyargcount" for positional-only arguments.
Similar to :c:func:`PyUnstable_Code_New`, but with an extra "posonlyargcount" for positional-only parameters.
The same caveats that apply to ``PyUnstable_Code_New`` also apply to this function.

.. index:: single: PyCode_NewWithPosOnlyArgs (C function)
Expand Down
2 changes: 1 addition & 1 deletion Doc/c-api/veryhigh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ the same library that the Python runtime is using.
evaluation. This environment consists of a dictionary of global variables,
a mapping object of local variables, arrays of arguments, keywords and
defaults, a dictionary of default values for :ref:`keyword-only
<keyword-only_parameter>` arguments and a closure tuple of cells.
<keyword-only_parameter>` parameters, and a closure tuple of cells.


.. c:function:: PyObject* PyEval_EvalFrame(PyFrameObject *f)
Expand Down
2 changes: 1 addition & 1 deletion Doc/deprecations/pending-removal-in-3.19.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Pending removal in Python 3.19
Support for the ``string`` keyword argument name is now deprecated
and slated for removal in Python 3.19.

Before Python 3.13, the ``string`` keyword parameter was not correctly
Before Python 3.13, the ``string`` keyword argument was not correctly
supported depending on the backend implementation of hash functions.
Prefer passing the initial data as a positional argument for maximum
backwards compatibility.
4 changes: 2 additions & 2 deletions Doc/faq/programming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ You could use a global variable containing a dictionary instead of the default
value; it's a matter of taste.


How can I pass optional or keyword parameters from one function to another?
---------------------------------------------------------------------------
How can I pass optional positional or keyword arguments from one function to another?
-------------------------------------------------------------------------------------

Collect the arguments using the ``*`` and ``**`` specifiers in the function's
parameter list; this gives you the positional arguments as a tuple and the
Expand Down
18 changes: 9 additions & 9 deletions Doc/howto/logging-cookbook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1634,7 +1634,7 @@ method. Since then, Python has gained two new formatting approaches:

Logging (as of 3.2) provides improved support for these two additional
formatting styles. The :class:`Formatter` class been enhanced to take an
additional, optional keyword parameter named ``style``. This defaults to
additional, optional keyword argument named ``style``. This defaults to
Comment on lines 1636 to +1637
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an alternative change, not necessarily better, would have been /take/have/.

``'%'``, but other possible values are ``'{'`` and ``'$'``, which correspond
to the other two formatting styles. Backwards compatibility is maintained by
default (as you would expect), but by explicitly specifying a style parameter,
Expand Down Expand Up @@ -1675,10 +1675,10 @@ That can still use %-formatting, as shown here::
>>>

Logging calls (``logger.debug()``, ``logger.info()`` etc.) only take
positional parameters for the actual logging message itself, with keyword
parameters used only for determining options for how to handle the actual
logging call (e.g. the ``exc_info`` keyword parameter to indicate that
traceback information should be logged, or the ``extra`` keyword parameter
positional arguments for the logging message itself, with keyword
arguments used only for determining options for how to handle the actual
logging call (e.g. the ``exc_info`` keyword argument to indicate that
traceback information should be logged, or the ``extra`` keyword argument
to indicate additional contextual information to be added to the log). So
you cannot directly make logging calls using :meth:`str.format` or
:class:`string.Template` syntax, because internally the logging package
Expand Down Expand Up @@ -2732,10 +2732,10 @@ governs the formatting of logging messages for final output to logs, and is
completely orthogonal to how an individual logging message is constructed.

Logging calls (:meth:`~Logger.debug`, :meth:`~Logger.info` etc.) only take
positional parameters for the actual logging message itself, with keyword
parameters used only for determining options for how to handle the logging call
(e.g. the ``exc_info`` keyword parameter to indicate that traceback information
should be logged, or the ``extra`` keyword parameter to indicate additional
positional arguments for the logging message itself, with keyword
arguments used only for determining options for how to handle the logging call
(e.g. the ``exc_info`` keyword argument to indicate that traceback information
should be logged, or the ``extra`` keyword argument to indicate additional
contextual information to be added to the log). So you cannot directly make
logging calls using :meth:`str.format` or :class:`string.Template` syntax,
because internally the logging package uses %-formatting to merge the format
Expand Down
13 changes: 7 additions & 6 deletions Doc/library/ast.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1930,21 +1930,22 @@ Function and class definitions

.. class:: arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults, kwarg, defaults)

The arguments for a function.
The parameters for the defined function.

* ``posonlyargs``, ``args`` and ``kwonlyargs`` are lists of :class:`arg` nodes.
* ``vararg`` and ``kwarg`` are single :class:`arg` nodes, referring to the
``*args, **kwargs`` parameters.
* ``kw_defaults`` is a list of default values for keyword-only arguments. If
* ``kw_defaults`` is the list of default values for keyword-only parameters. If
one is ``None``, the corresponding argument is required.
* ``defaults`` is a list of default values for arguments that can be passed
positionally. If there are fewer defaults, they correspond to the last n
arguments.
* ``defaults`` is the list of default values for positional-only and
keyword-or-positional parameters.
If there are fewer defaults than there are such parameters, the defaults correspond to the last *n*
parameters.


.. class:: arg(arg, annotation, type_comment)

A single argument in a list. ``arg`` is a raw string of the argument
A single parameter in a list. ``arg`` is a raw string of the parameter
name; ``annotation`` is its annotation, such as a :class:`Name` node.

.. attribute:: type_comment
Expand Down
10 changes: 5 additions & 5 deletions Doc/library/asyncio-eventloop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Scheduling callbacks
Callbacks are called in the order in which they are registered.
Each callback will be called exactly once.

The optional keyword-only *context* argument specifies a
The optional keyword argument *context* specifies a
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove "only"? I don't see anything wrong with calling these "keyword-only".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering my own question after reading more of the diff: "only" means nothing for arguments, since an argument is only ever keyword or positional, not both. So arguments are either positional or keyword; "keyword-only" makes sense only for parameters because parameters can be both at once.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the -only is redundant, but it does make things clearer.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the parameter was keyword-or-positional, we would say "The optional argument context".

Copy link
Member

@terryjreedy terryjreedy Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Jelle's 2nd comment that -only can be left removed here and below.

custom :class:`contextvars.Context` for the *callback* to run in.
Callbacks use the current context when no *context* is provided.

Expand Down Expand Up @@ -296,11 +296,11 @@ clocks to track time.
scheduled for exactly the same time, the order in which they
are called is undefined.

The optional positional *args* will be passed to the callback when
The optional positional arguments *args* will be passed to the callback when
it is called. If you want the callback to be called with keyword
arguments use :func:`functools.partial`.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the *callback* to run in.
The current context is used when no *context* is provided.

Expand Down Expand Up @@ -377,11 +377,11 @@ Creating Futures and Tasks
If the *name* argument is provided and not ``None``, it is set as
the name of the task using :meth:`Task.set_name`.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the *coro* to run in.
The current context copy is created when no *context* is provided.

An optional keyword-only *eager_start* argument allows specifying
An optional keyword argument *eager_start* allows specifying
if the task should execute eagerly during the call to create_task,
or be scheduled later. If *eager_start* is not passed the mode set
by :meth:`loop.set_task_factory` will be used.
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-future.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Future Object
If the Future is already *done* when this method is called,
the callback is scheduled with :meth:`loop.call_soon`.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the *callback* to run in.
The current context is used when no *context* is provided.

Expand Down
6 changes: 3 additions & 3 deletions Doc/library/asyncio-graph.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ and debuggers.
If not passed, the current running task will be used.

If the function is called on *the current task*, the optional
keyword-only *depth* argument can be used to skip the specified
keyword argument *depth* can be used to skip the specified
number of frames from top of the stack.

If the optional keyword-only *limit* argument is provided, each call stack
If the optional keyword argument *limit* is provided, each call stack
in the resulting graph is truncated to include at most ``abs(limit)``
entries. If *limit* is positive, the entries left are the closest to
the invocation point. If *limit* is negative, the topmost entries are
Expand Down Expand Up @@ -91,7 +91,7 @@ and debuggers.
current task, the function returns ``None``.

If the function is called on *the current task*, the optional
keyword-only *depth* argument can be used to skip the specified
keyword argument *depth* can be used to skip the specified
number of frames from top of the stack.

Returns a ``FutureCallGraph`` data class object:
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/asyncio-runner.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Runner context manager

If the argument is a coroutine, it is wrapped in a Task.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the code to run in.
The runner's default context is used if context is ``None``.

Expand Down
8 changes: 4 additions & 4 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ Creating Tasks
:class:`Task` constructor (or factory) - all of the keyword arguments to
this function are passed through to that interface.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the *coro* to run in.
The current context copy is created when no *context* is provided.

An optional keyword-only *eager_start* argument allows specifying
An optional keyword argument *eager_start* allows specifying
if the task should execute eagerly during the call to create_task,
or be scheduled later. If *eager_start* is not passed the mode set
by :meth:`loop.set_task_factory` will be used.
Expand Down Expand Up @@ -1232,12 +1232,12 @@ Task Object
APIs except :meth:`Future.set_result` and
:meth:`Future.set_exception`.

An optional keyword-only *context* argument allows specifying a
An optional keyword argument *context* allows specifying a
custom :class:`contextvars.Context` for the *coro* to run in.
If no *context* is provided, the Task copies the current context
and later runs its coroutine in the copied context.

An optional keyword-only *eager_start* argument allows eagerly starting
An optional keyword argument *eager_start* allows eagerly starting
the execution of the :class:`asyncio.Task` at task creation time.
If set to ``True`` and the event loop is running, the task will start
executing the coroutine immediately, until the first time the coroutine
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ they add the ability to access fields by name instead of position index.

.. versionchanged:: 3.6
The *verbose* and *rename* parameters became
:ref:`keyword-only arguments <keyword-only_parameter>`.
:ref:`keyword-only parameters <keyword-only_parameter>`.

.. versionchanged:: 3.6
Added the *module* parameter.
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/configparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ even if we specify a fallback:
One more thing to be aware of is that the parser-level :meth:`~ConfigParser.get` method
provides a custom, more complex interface, maintained for backwards
compatibility. When using this method, a fallback value can be provided via
the ``fallback`` keyword-only argument:
the ``fallback`` keyword argument:

.. doctest::

Expand Down Expand Up @@ -1182,9 +1182,9 @@ ConfigParser Objects
in the same manner as the option.

.. versionchanged:: 3.2
Arguments *raw*, *vars* and *fallback* are keyword only to protect
users from trying to use the third argument as the *fallback* fallback
(especially when using the mapping protocol).
Parameters *raw*, *vars* and *fallback* are keyword-only to protect
users from trying to use the third positional argument as the
*fallback* (especially when using the mapping protocol).


.. method:: getint(section, option, *, raw=False, vars=None[, fallback])
Expand Down
2 changes: 1 addition & 1 deletion Doc/library/contextvars.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Context Variables
The required *name* parameter is used for introspection and debug
purposes.

The optional keyword-only *default* parameter is returned by
If the optional keyword argument *default* is specified, it will be returned by
:meth:`ContextVar.get` when no value for the variable is found
in the current context.

Expand Down
2 changes: 1 addition & 1 deletion Doc/library/curses.rst
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ the following methods and attributes:
.. note::

A ``0`` value for any parameter will cause the default character to be used for
that parameter. Keyword parameters can *not* be used. The defaults are listed
that parameter. Keyword arguments can *not* be used. The defaults are listed
in this table:

+-----------+---------------------+-----------------------+
Expand Down
8 changes: 4 additions & 4 deletions Doc/library/difflib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
*tabsize* is an optional keyword argument to specify tab stop spacing and
defaults to ``8``.

*wrapcolumn* is an optional keyword to specify column number where lines are
*wrapcolumn* is an optional keyword argument to specify column number where lines are
broken and wrapped, defaults to ``None`` where lines are not wrapped.

*linejunk* and *charjunk* are optional keyword arguments passed into :func:`ndiff`
Expand Down Expand Up @@ -133,7 +133,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
properly escaped while receiving input from untrusted sources.

.. versionchanged:: 3.5
*charset* keyword-only argument was added. The default charset of
*charset* keyword-only parameter was added. The default charset of
HTML document changed from ``'ISO-8859-1'`` to ``'utf-8'``.

.. method:: make_table(fromlines, tolines, fromdesc='', todesc='', context=False, numlines=5)
Expand Down Expand Up @@ -225,7 +225,7 @@ diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
delta (a :term:`generator` generating the delta lines).

Optional keyword parameters *linejunk* and *charjunk* are filtering functions
Optional keyword arguments *linejunk* and *charjunk* are filtering functions
(or ``None``):

*linejunk*: A function that accepts a single string argument, and returns
Expand Down Expand Up @@ -652,7 +652,7 @@ The :class:`Differ` class has this constructor:
.. class:: Differ(linejunk=None, charjunk=None)
:noindex:

Optional keyword parameters *linejunk* and *charjunk* are for filter functions
Optional keyword arguments *linejunk* and *charjunk* are for filter functions
(or ``None``):

*linejunk*: A function that accepts a single string argument, and returns true
Expand Down
6 changes: 3 additions & 3 deletions Doc/library/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
assignment fails. (When an object does not support attribute references or
attribute assignments at all, :exc:`TypeError` is raised.)

The :attr:`name` and :attr:`obj` attributes can be set using keyword-only
The :attr:`name` and :attr:`obj` attributes can be set using keyword

Check warning on line 207 in Doc/library/exceptions.rst

View workflow job for this annotation

GitHub Actions / Docs / Docs

py:attr reference target not found: name [ref.attr]
arguments to the constructor. When set they represent the name of the attribute
that was attempted to be accessed and the object that was accessed for said
attribute, respectively.
Expand Down Expand Up @@ -238,7 +238,7 @@
load a module. Also raised when the "from list" in ``from ... import``
has a name that cannot be found.

The optional *name* and *path* keyword-only arguments
The optional *name* and *path* keyword arguments
set the corresponding attributes:

.. attribute:: name
Expand Down Expand Up @@ -312,7 +312,7 @@
unqualified names. The associated value is an error message that includes the
name that could not be found.

The :attr:`name` attribute can be set using a keyword-only argument to the
The :attr:`name` attribute can be set passing a keyword argument to the
constructor. When set it represent the name of the variable that was attempted
to be accessed.

Expand Down
Loading
Loading