This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Doc for mutable sequence pop() method implies argument is a slice or sequence.
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, msapiro, rhettinger
Priority: normal Keywords:

Created on 2021-05-01 00:34 by msapiro, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg392551 - (view) Author: Mark Sapiro (msapiro) * (Python triager) Date: 2021-05-01 00:34
In several places in the documentation including:

```
grep -rn 'pop.\[i\]'
Lib/pydoc_data/topics.py:13184:             '| "s.pop([i])"                   | retrieves the item at *i* '
Lib/pydoc_data/topics.py:13647:                     '| "s.pop([i])"                   | retrieves the item at '
Doc/tutorial/datastructures.rst:47:.. method:: list.pop([i])
Doc/library/array.rst:193:.. method:: array.pop([i])
Doc/library/stdtypes.rst:1116:| ``s.pop([i])``               | retrieves the item at *i* and  | \(2)                |
```
the mutable sequence and array `pop()` method is documented as shown above in a way that implies the argument to `pop()` is a slice or sequence when it is actually just an integer. All those references should be `pop(i)` rather than `pop([i])`.
msg392567 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2021-05-01 03:12
In function signatures, the square brackets do not mean that there is a list.  Instead, it is a convention used throughout the docs to mean that an argument is optional.  In this case, s.pop([i]) means that both of these are valid calls:

    # retrieve and remove the value at a specific position
    somelist.pop(10)

    # retrieve and remove the rightmost value 
    somelist.pop()      

Thank you for the report, but the documentation is correct.
msg392569 - (view) Author: Mark Sapiro (msapiro) * (Python triager) Date: 2021-05-01 03:51
Thank you for the explanation which I understand and accept. I also fully (or maybe not quite fully) understand the use of square brackets to indicate optional arguments. It's just that in the context of the table at https://docs.python.org/3/library/stdtypes.html#mutable-sequence-types every other use of square brackets indicates a list or a slice and that's what confused me. Granted, all the other square bracket usage was not around a method argument, and I accept that the doc is correct, but I still found it confusing.
History
Date User Action Args
2022-04-11 14:59:45adminsetgithub: 88162
2021-05-01 03:51:20msapirosetmessages: + msg392569
2021-05-01 03:12:27rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg392567

resolution: not a bug
stage: resolved
2021-05-01 00:34:44msapirocreate