On 10/27/2013 07:03 PM, Rob Cliffe wrote:
I'd like to throw in an idea. Not sure how serious it is (prepared to be shot down in flames :-) ), just want to be sure that all possibilities are examined.
I think your safe. ;-)
With positive strides, "start" is inclusive, "end" is exclusive". Suppose that with negative strides, "start" were exclusive and "end" was inclusive.
With the proposed behaviour, (That you and Tim described), it will be easier to think in terms of [left:right:step]. And it fits with Guido's ... s[left:right:-step] == s[left:right][::-step] One of the nice properties is that you can switch directions by just changing the step. With the current slice's, you need to change the start and stop as well. And also recalculate those if you want the same range. BTW. A negative step will only be the exact reversed sequence if the last item is also (j-1) for that step value. Cheers, Ron
(I.e. the "lower" bound was always inclusive and the "upper" bound was always exclusive.) Then "abcde"[:2:-1] would be "edc", not "ed". Then "abcde"[:1:-1] would be "edcb", not "edc". Then "abcde"[:0:-1] would be "edcba". I think this fits in with Tim Peters' concept of characters between positions, e.g. "abcde"[3:0:-1] would be "cba" (not "dcb" as at present), i.e. the characters between positions 0 and 3. Rob Cliffe