-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
library/stdtypes.html - Mutable Sequence Types - Operations Table - Slice Assignments #119003
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
Labels
docs
Documentation in the Doc dir
Comments
It should be noted that this behavior is also exhibited when using the shorter colon notation for slices as well
|
hauntsaninja
pushed a commit
that referenced
this issue
Jun 21, 2024
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 21, 2024
(cherry picked from commit 4628320) Co-authored-by: Nice Zombies <[email protected]>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this issue
Jun 21, 2024
(cherry picked from commit 4628320) Co-authored-by: Nice Zombies <[email protected]>
kumaraditya303
pushed a commit
that referenced
this issue
Jun 23, 2024
kumaraditya303
pushed a commit
that referenced
this issue
Jun 23, 2024
mrahtz
pushed a commit
to mrahtz/cpython
that referenced
this issue
Jun 30, 2024
noahbkim
pushed a commit
to hudson-trading/cpython
that referenced
this issue
Jul 11, 2024
estyxx
pushed a commit
to estyxx/cpython
that referenced
this issue
Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Documentation
The table of operations for mutable sequence types has footnote (1) for the operation
s[i:j:k] = t
, which states that "t must have the same length as the slice it is replacing." When the step size of the slice (k) is 1, the slice object behaves the same as the operations[i:j] = t
. When creating slices with similar values, these slices are distinct:But when these slices are used in mutable sequence assignment, they behave the same:
This is only when the step (k) is 1, as shown by the following example:
Since the example
s[i:j:k] = t
does not behave the same when k = 1 compared to k > 1, the documentation should be updated. My proposed change is footnote (1) reads as follows:s[i:j] = t
, otherwise t must have the same length as the slice it is replacing. If t is not the same length as the slice it is replacing and k does not equal 1, then a ValueError is raised.Linked PRs
The text was updated successfully, but these errors were encountered: