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

Alexander Belopolsky alexander.belopolsky at gmail.com
Tue Oct 29 01:45:13 CET 2013


On Mon, Oct 28, 2013 at 6:41 PM, Guido van Rossum <guido at python.org> wrote:
> I'm not sure I like new syntax.

Neither do I, but I've never liked the current extended slicing syntax either.

> We'd still have to find a way to represent this with slice() and also with
> range().

These seem easy: slice(i, j, k, reverse=True) and range(i, j, k, reverse=True).

FWIW, I won't miss extended slicing syntax if it goes away in Python
4.  I find a[slice(i, j, step=2, reverse=True)]  more readable than
a[i:j:-k].  Alternatively, we can allow keyword arguments like syntax
inside []:  a[i:j,step=2, reverse=True] can become syntactic sugar for
a[slice(i, j, step=2, reverse=True)] .


More information about the Python-ideas mailing list