[Python-Dev] PEP Proposal: Revised slice objects & lists use slice objects as indexes

Alex Martelli aleaxit at gmail.com
Tue Mar 11 02:21:53 CET 2008

On Mon, Mar 10, 2008 at 3:57 AM, Forrest Voight <voights at gmail.com> wrote:
> >  I am not sure what you are trying to propose here. The slice object
>  >  isn't special, it's just a regular built-in type.
>   The idea is to have slice objects be generators. You could make a
>   slice like 1:10:2 , and that would make a slice object which could be
>   used as a list index. The list would return a list with the
>   corresponding item for every index in the generator. Then, lists could

And what indices would the slice 1:-1 return, for example?  Your
proposal can't play well with slices including negative indices.

Also, your desired use case of alist[indices] is already pretty well
covered by [alist[i] for i in indices].


More information about the Python-Dev mailing list