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

Nick Coghlan ncoghlan at gmail.com
Wed Oct 30 11:22:22 CET 2013


On 30 October 2013 20:13, Oscar Benjamin <oscar.j.benjamin at gmail.com> wrote:
> But you currently need to write it that way to get the correct behaviour:
>
>>>> for n in reversed(range(4)):
> ...     print(n, a[len(a)-n:])
> ...
> 3 cde
> 2 de
> 1 e
> 0

Regardless, my main point is this: slices are just objects. The syntax:

   s[i:j:k]

is just syntactic sugar for:

  s[slice(i, j, k)]

That means that until people have fully explored exactly the semantics
they want in terms of the existing object model, just as I did for
rslice(), then there are *zero* grounds to be discussing syntax
changes that provide those new semantics.

Regards,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-ideas mailing list