Skip to content
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

Off-by-one index error in __main__.py doc #112165

Closed
vanyolos opened this issue Nov 16, 2023 · 3 comments
Closed

Off-by-one index error in __main__.py doc #112165

vanyolos opened this issue Nov 16, 2023 · 3 comments
Labels
docs Documentation in the Doc dir

Comments

@vanyolos
Copy link

vanyolos commented Nov 16, 2023

Very minor issue, the '2' here should be '3' on the RHS of the comparison (given we really want to return sys.argv[2] from the ternary).

image

https://docs.python.org/3.10/library/__main__.html

Linked PRs

@vanyolos vanyolos added the docs Documentation in the Doc dir label Nov 16, 2023
@hugovk
Copy link
Member

hugovk commented Nov 16, 2023

If you run the example as:

python3 -m bandclass my-name

Then sys.argv contains ['/private/tmp/bandclass/__main__.py', 'my-name']

So do we want this?

student_name = sys.argv[1] if len(sys.argv) >= 2 else ''

@vanyolos
Copy link
Author

vanyolos commented Nov 16, 2023

Yes, that should be the fix indeed. Can you pls make the fix/PR?
(I checked, other python version docs are also affected, like 3.11, etc.)

I have no idea how to do it, new to github and this was first time ever reading official python docs. But you gotta start somewhere

@vanyolos vanyolos reopened this Nov 16, 2023
@terryjreedy
Copy link
Member

I'm making the PR, but if you want to learn to do it, start with https://devguide.python.org/.

terryjreedy added a commit to terryjreedy/cpython that referenced this issue Nov 17, 2023
Change '[2]' to '[1]' to get second argument.
terryjreedy added a commit that referenced this issue Nov 17, 2023
Change '[2]' to '[1]' to get second argument.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 17, 2023
Change '[2]' to '[1]' to get second argument.
(cherry picked from commit 8cd70ee)

Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 17, 2023
Change '[2]' to '[1]' to get second argument.
(cherry picked from commit 8cd70ee)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Nov 17, 2023
gh-112165: Fix typo in `__main__.py` (GH-112183)

Change '[2]' to '[1]' to get second argument.
(cherry picked from commit 8cd70ee)

Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Nov 17, 2023
gh-112165: Fix typo in `__main__.py` (GH-112183)

Change '[2]' to '[1]' to get second argument.
(cherry picked from commit 8cd70ee)

Co-authored-by: Terry Jan Reedy <[email protected]>
aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Change '[2]' to '[1]' to get second argument.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Change '[2]' to '[1]' to get second argument.
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

No branches or pull requests

3 participants