[Python-ideas] Where did we go wrong with negative stride?

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Oct 29 01:47:56 CET 2013


On Mon, Oct 28, 2013 at 7:13 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
..
> to effectively mean:
>
>     range(i, j, k)[::-1]
>
> and for:
>
>     s[slice(i, j, k, reverse=True)]
>
> to effectively mean:
>
>     s[i:j:k][::-1]
>
> range and slice would handle the appropriate start/stop/step calculations
> under the hood and hence be backwards compatible with existing container
> implementations and other code.
>
> This approach also means we could avoid addressing the slice reversal syntax
> question for 3.4, and revisit it in the 3.5 time frame (and ditto for
> deprecating negative strides). However, the idea of just allowing keyword
> args to be passed to the slice builtin in the slice syntax did occur to me:
>
>     s[i:j:k:reverse=True]

+1

In fact, I suggested the same before reading your e-mail.


More information about the Python-ideas mailing list