Skip to content

gh-114648: Add IndexError exception to tutorial datastructures list.pop entry #114681

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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 1, 2024

Conversation

ShivnarenSrinivasan
Copy link
Contributor

@ShivnarenSrinivasan ShivnarenSrinivasan commented Jan 28, 2024

To be consistent with the other two methods which have documented exceptions.


馃摎 Documentation preview 馃摎: https://cpython-previews--114681.org.readthedocs.build/

To be consistent with the other two `list` methods (`remove` and `insert`) which have documented exceptions.
will see this notation frequently in the Python Library Reference.)
is specified, ``a.pop()`` removes and returns the last item in the list.
It raises an :exc:`IndexError` if the list is empty or the index is
outside the list range. (The square brackets around the *i* in the method
Copy link
Member

Choose a reason for hiding this comment

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

I also think that we can remove this note. Since the [arg] notation is used all over the docs, here is not the right place for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree--didn't want to do that on my own accord, but yes.

Copy link
Member

Choose a reason for hiding this comment

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

If you think something should be removed, you can ask in a comment.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry to comment after merge!

Re:

(The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)

It's in the tutorial, which is introducing people to Python, and at the top of the page where this notation first appears.

Di谩taxis says of tutorials:

A tutorial is an experience that takes place under the guidance of a tutor. A tutorial is always learning-oriented.

People do read through the tutorial from start to finish, and I think this is a good place to introduce and teach this notation.

@terryjreedy terryjreedy changed the title gh-114648: Added IndexError exception to tutorial. gh-114648: Add IndexError exception to tutorial datastructures list.pop entry Feb 1, 2024
@terryjreedy terryjreedy added needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Feb 1, 2024
@terryjreedy terryjreedy merged commit 57c3e77 into python:main Feb 1, 2024
@miss-islington-app
Copy link

Thanks @ShivnarenSrinivasan for the PR, and @terryjreedy for merging it 馃尞馃帀.. I'm working now to backport this PR to: 3.11, 3.12.
馃悕馃崚鉀忦煠�

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 1, 2024
鈥ist.pop entry (pythonGH-114681)

Remove redundant explanation of optional argument.
(cherry picked from commit 57c3e77)

Co-authored-by: srinivasan <shivnaren@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 1, 2024
鈥ist.pop entry (pythonGH-114681)

Remove redundant explanation of optional argument.
(cherry picked from commit 57c3e77)

Co-authored-by: srinivasan <shivnaren@gmail.com>
@bedevere-app
Copy link

bedevere-app bot commented Feb 1, 2024

GH-114841 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 1, 2024
@bedevere-app
Copy link

bedevere-app bot commented Feb 1, 2024

GH-114842 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 1, 2024
terryjreedy pushed a commit that referenced this pull request Feb 1, 2024
鈥� list.pop entry (GH-114681) (#114841)

Remove redundant explanation of optional argument.
(cherry picked from commit 57c3e77)

Co-authored-by: srinivasan <shivnaren@gmail.com>
terryjreedy pushed a commit that referenced this pull request Feb 1, 2024
鈥� list.pop entry (GH-114681) (#114842)

Remove redundant explanation of optional argument.
(cherry picked from commit 57c3e77)

Co-authored-by: srinivasan <shivnaren@gmail.com>
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
鈥ist.pop entry (python#114681)

Remove redundant explanation of optional 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 skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants