Slicing with negative strides

Peter Cacioppi peter.cacioppi at gmail.com
Wed Nov 6 14:15:02 EST 2013


On Monday, October 28, 2013 10:22:00 PM UTC-7, Steven D'Aprano wrote:
> Does anyone here use slices (or range/xrange) with negative strides other 
> 
> than -1?
> 

Non default positive strides are very handy, but negative strides seem weird to me. Not the negative striding exactly, but the way fenceposts and negative strides interact.

For example, this poster seems to posit a canonical WTF with negative strides. 

http://stackoverflow.com/questions/5798136/python-reverse-stride-slicing

I can almost picture Picard saying "WTF do you need to omit the end index to get the zero element??!!"

Readability counts, no? Just reverse it and use positive strides. 








More information about the Python-list mailing list