Closed
Description
Documentation
Operation | Result | Notes |
---|---|---|
s[i] |
ith item of s, origin 0 | (3) |
- If i or j is negative, the index is relative to the end of sequence s:
len(s) + i
orlen(s) + j
is substituted. But note that-0
is still0
.
We can add a note: If the sequence is empty or i is outside the sequence range, IndexError
will be raised.
Linked PRs
Metadata
Metadata
Assignees
Projects
Status
Todo
Activity
s[i]
#134977picnixz commentedon May 31, 2025
I'm surprised that there is nothing about
IndexError
on this pageterryjreedy commentedon May 31, 2025
I believe that while negative indexes are implemented for (most?) builtins, this is not necessarily the case for all sequences.
picnixz commentedon May 31, 2025
Note (3) still says:
So the common sequence operations assume that negative indices should be supported by arbitrary sequences.
gh-134976: document the exception type that can be raised by `s[i]` (#…
pythongh-134976: document the exception type that can be raised by `s…
s[i]
(GH-134977) #135258s[i]
(GH-134977) #135259[3.14] gh-134976: document the exception type that can be raised by `…
[3.13] gh-134976: document the exception type that can be raised by `…
picnixz commentedon Jun 8, 2025
Thank you!
4 remaining items