Skip to content

Tutorial section 4.9.3 "Special Parameters" buries / and * symbols in text #151395

@CloudeaSoft

Description

@CloudeaSoft

Location

https://docs.python.org/3/tutorial/controlflow.html#special-parameters

Current text

Special parameters
------------------
By default, arguments may be passed to a Python function either by position
or explicitly by keyword. For readability and performance, it makes sense to
restrict the way arguments can be passed so that a developer need only look
at the function definition to determine if items are passed by position, by
position or keyword, or by keyword.
A function definition may look like:
.. code-block:: none
def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):
----------- ---------- ----------
| | |
| Positional or keyword |
| - Keyword only
-- Positional only
where ``/`` and ``*`` are optional. If used, these symbols indicate the kind of
parameter by how the arguments may be passed to the function:
positional-only, positional-or-keyword, and keyword-only. Keyword parameters
are also referred to as named parameters.

Problem

This section is about / and * — two symbols that control how arguments are passed. But the paragraph never mentions them at the beginning. The reader has to:

  1. Read an abstract sentence about "position or keyword"
  2. Scan through a code example
  3. Read further explanations

Only then do they finally see what the section is actually about. The two symbols (/ and *) are visually buried inside a longer line of code:

def f(pos1, pos2, /, pos_or_kwd, *, kwd1, kwd2):

The main characters should be introduced in the first sentence, not hidden in the middle of a code block.

Suggestion

Consider opening the section by explicitly naming / and * and stating what they do.

Readers (especially beginners) can immediately understand what the section covers and what the symbols look like, without having to dig through abstract text first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir
    No fields configured for issues without a type.

    Projects

    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions