Skip to content

doc: use less ambiguously named variable #113113

@jeremy-dolan

Description

@jeremy-dolan

Documentation

In the control flow tutorial -- https://docs.python.org/3/tutorial/controlflow.html -- one of the examples uses 'ok' as the variable name to capture input(). 'Ok' is ambiguous and, at least to me, read as a boolean type when I was learning python with the tutorials. Since the following code processes ok with some Python-specific syntax (a container check against a tuple of strings), as a new user it was hard to understand what was going on. I propose changing the variable name to 'reply' to more clearly indicate to the tutorial reader that it's storing unevaluated user input, without the affirmative connotations of the name 'ok'. PR forthcoming.

Example in question:

while True:
    ok = input(prompt)
    if ok in ('y', 'ye', 'yes'):
        return True
    if ok in ('n', 'no', 'nop', 'nope'):
        return False

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions