negative stride list slices

Reid Nichol rnichol_rrc at yahoo.com
Wed Sep 1 14:01:50 EDT 2004


David Abrahams wrote:
> Can anyone explain the logic behind the behavior of list slicing with
> negative strides?  For example:
> 
>   >>> print range(10)[:-3:-1]
>   [9,8]
> 
> I found this result very surprising, and would just like to see the
> rules written down somewhere.
> 
> Thanks,
> --
> Dave Abrahams
> Boost Consulting
> http://www.boost-consulting.com

http://www.python.org/doc/current/tut/node5.html#SECTION005120000000000000000



More information about the Python-list mailing list