On Sun, Oct 27, 2013 at 4:45 PM, Greg Ewing <greg.ewing@canterbury.ac.nz>wrote:
I think the only way to really fix this cleanly is to have a different *syntax* for counting from the end, rather than trying to guess from the value of the argument.
I was thinking the exact same thing today. Suppose the slice syntax was changed to: [start:stop:stride:reverse] where 0 or None or False for reverse leaves the slice in order while any True value reverses it. This would replace 'abcde'[2:5] == 'bcd' 'abcde'[2:5::True] == 'dcb' 'abcde'[::-2] == 'abcde'[::2:True] == 'eca' 'abcdef'[::-2] == 'fdb' 'abcdef'[::2:True] == 'eca' As the last three examples, illustrate, sometimes the reverse is equivalent to a negative stride and sometimes it's not. --- Bruce I'm hiring: http://www.cadencemd.com/info/jobs Latest blog post: Alice's Puzzle Page http://www.vroospeak.com Learn how hackers think: http://j.mp/gruyere-security