Backward list indices
Erik Max Francis
max at alcyone.com
Thu Dec 19 21:39:31 EST 2002
Terry Reedy wrote:
> "Nicola Larosa" <googlegroups at tekNico.net> wrote in message
> news:6fb43e5d.0212191514.3b92bc51 at posting.google.com...
>
> > Why is that so? It would seem natural that, if i is greater than or
> > equal to j, the slice is populated with the items in backward order,
> > be it myList[5:3] or myList[-3:-7] .
>
> This never occurred to me. I have no idea whether Guido ever
> considered it. Does seem a bit natural in retrospect.
Neglecting the fact that changing it now would break existing code
relying on its current behavior, I think the obvious question is whether
or not a slice of the form L[m:n] where m > n is more likely to
represent programmer error rather than some meaningful attempt to get a
reversed slice.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ I'm trying to forget / But I can't act as if we never met
\__/ Chante Moore
PyUID / http://www.alcyone.com/pyos/uid/
A module for generating "unique" IDs in Python.
More information about the Python-list
mailing list