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

Serhiy Storchaka storchaka at gmail.com
Sun Oct 27 19:07:36 CET 2013


27.10.13 19:04, Guido van Rossum написав(ла):
> In the comments of
> http://python-history.blogspot.com/2013/10/why-python-uses-0-based-indexing.html
> there were some complaints about the interpretation of the bounds for
> negative strides, and I have to admin it feels wrong. Where did we go
> wrong? For example,
>
> "abcde"[::-1] == "edcba"
>
> as you'd expect, but there is no number you can put as the second bound
> to get the same result:

But you can put None.

 >>> "abcde"[:None:-1]
'edcba'




More information about the Python-ideas mailing list