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

Rob Cliffe rob.cliffe at btinternet.com
Mon Oct 28 01:08:14 CET 2013


On 27/10/2013 23:34, Rob Cliffe wrote:
>
>> I wonder if it would have been simpler if we had defined a[i:j:-1] as 
>> the reverse of a[i:j]?
>>
> Maybe, I'm not venturing an opinion.
> But if so:  What about negative strides other than -1?  Should 
> a[i:j:-2] always be the reverse of a[i:j:2]?
> My feeling is not, i.e.
> "abcdefghij"[3:8:2] == "dfh"
> but I feel that
> "abcdefghij"[3:8:-2] under this suggestion should be what 
> "abcdefghij"[8:3:-2] is now, i.e. "ige", not "hfd".
> I.e. any non-empty start:stop:stride slice where 0 <= slice < length 
> should always start with the character indexed by "start".
Correction: I meant "where 0 <= start < length".  On reconsideration, 
please ignore this condition.
> Rob Cliffe
>> What are real use cases for negative strides?
>>
>> -- 
>> --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
>>
>>
>> _______________________________________________
>> Python-ideas mailing list
>> Python-ideas at python.org
>> https://mail.python.org/mailman/listinfo/python-ideas
>>
>>
>> No virus found in this message.
>> Checked by AVG - www.avg.com <http://www.avg.com>
>> Version: 2012.0.2242 / Virus Database: 3222/6285 - Release Date: 10/27/13
>>
>
>
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
>
>
> No virus found in this message.
> Checked by AVG - www.avg.com <http://www.avg.com>
> Version: 2012.0.2242 / Virus Database: 3222/6285 - Release Date: 10/27/13
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131028/40e687ac/attachment.html>


More information about the Python-ideas mailing list