Negative array indicies and slice()

Paul Rubin no.email at nospam.invalid
Mon Oct 29 01:14:03 EDT 2012


Andrew <andrewr3mail at gmail.com> writes:
> So: Why does python choose to convert them to positive indexes, and
> have slice operate differently than xrange 

There was a thread a few years back, I think started by Bryan Olson,
that made the case that slice indexing is a Python wart for further
reasons than the above, and suggesting a notation like x[$-5] to denote
what we now call x[-5] (i.e. $ is the length of the string).  So your
example x[$-4:3] would clearly be the same thing as x[6:3] and not give
any suggestion that it might wrap around.



More information about the Python-list mailing list