negative stride list slices

Russell Blau russblau at hotmail.com
Wed Sep 1 14:35:53 EDT 2004


"Reid Nichol" <rnichol_rrc at yahoo.com> wrote in message
news:r7oZc.6653$MR2.32885 at news1.mts.net...
> 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.
>
http://www.python.org/doc/current/tut/node5.html#SECTION005120000000000000000

You probably meant to reference the next section (that bookmark relates to
strings, the next one is lists), but in either case none of the examples in
the tutorial has yet been updated to deal with slices that include a
"stride" as a third parameter.


-- 
I don't actually read my hotmail account, but you can replace hotmail with
excite if you really want to reach me.





More information about the Python-list mailing list