[docs] [issue32288] Inconsistent behavior with slice assignment?

R. David Murray report at bugs.python.org
Tue Dec 12 09:10:32 EST 2017


R. David Murray <rdmurray at bitdance.com> added the comment:

It actually makes sense that a slice assignment with a different length replacement list with a step of 1 works but any other step doesn't.  Logically you can see that you can cut out a chunk and replace it with a different sized chunk, but you can't do that if the step is not abs(1).  So a doc tweak may be appropriate.  And it is surprising that -1 doesn't work (but why would you ever use it? :), so that might be a buglet.

For a numpy array, I imagine the rules are different, so an error there on stride 1 is not that surprising either, though *perhaps* there is room for improvement on the numpy side.  (In other words, the stride 1 python behavior is "correct" from a python language perspective.)

And yes, it would be much easier to discuss these separate issues in separate issues.  Now you know for next time :)

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32288>
_______________________________________


More information about the docs mailing list