negative stride list slices

Russell Blau russblau at hotmail.com
Wed Sep 1 20:34:45 CEST 2004


"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message
news:mailman.2732.1094061711.5135.python-list at python.org...
> [dave at boost-consulting.com]
>
> #-   >>> print range(10)[:-3:-1]
> #-   [9,8]
> #-
> #- I found this result very surprising, and would just like to see the
> #- rules written down somewhere.
>
> Slice objects
>     Slice objects are used to represent slices when extended slice syntax
is
> used. This is a slice using two colons, or multiple slices or ellipses
> separated by commas, e.g., a[i:j:step], a[i:j, k:l], or a[..., i:j]. They
> are also created by the built-in slice() function.
>
>     Special read-only attributes: start is the lower bound; stop is the
> upper bound; step is the step value; each is None if omitted. These
> attributes can have any type.
>
> (from http://www.python.org/dev/doc/devel/ref/types.html#types)

That defines what a slice is; it doesn't define how a list (or other object)
will behave when presented with a slice object as an index.


-- 
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