negative stride list slices

Peter Hansen peter at
Thu Sep 2 00:05:22 CEST 2004

(Please don't top-post.  It really buggers up the quoting
and makes discussion hard.)

Julio Oña wrote:

> Slice has three arguments, [begin:end:step]
> when doing s[:-3:-1] you are asking the las to elements of the list in
> reversed order.

Uh, yeah.  Okay.  So let's say that part was obvious.  Now
please explain *which* elements are being listed in reverse
order, referring to the index value -3 and the elided
index value.  Presumably one of those refers to the beginning
or end of the list, while the other one refers to something
that is referenced as "-3".  Can you point to a diagram or
description in the documentation or tutorial which actually
explains this?  Or can you (or anyone) explain it in your
own words?  Or is everyone who thinks this makes sense just
pretending to actually understand it?


More information about the Python-list mailing list