Thanks to visit codestin.com
Credit goes to github.com

Skip to content

doc: use less ambiguously named variable #113113

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

Closed
jeremy-dolan opened this issue Dec 14, 2023 · 0 comments · Fixed by #113114
Closed

doc: use less ambiguously named variable #113113

jeremy-dolan opened this issue Dec 14, 2023 · 0 comments · Fixed by #113114
Labels
docs Documentation in the Doc dir

Comments

@jeremy-dolan
Copy link
Contributor

jeremy-dolan commented Dec 14, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants