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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Mar 11 00:07:46 CET 2008


Forrest Voight wrote:
> Slice objects that are produced in a list index area would be different,
> and optionally the syntax for slices in list indexes would be expanded
> to work everywhere.

Something like this was quite close to getting in a while
back, but it was eventually dropped. Anyone advocating this
should probably look back over the discussion and find out
why. I think they were to be called "range expressions" or
something like that.

A point to consider is that iterating over a range of
integers is actually quite a rare thing to do in idiomatic
Python. It's much more common to iterate directly over a
sequence of things you want to operate on.

This is even more true now that we have enumerate(). So
this proposal is addressing a fairly small set of use
cases.

-- 
Greg


More information about the Python-Dev mailing list