Proposed PEP: New style indexing, was Re: Bug in slice type
steven.bethard at gmail.com
Sat Aug 20 23:33:22 CEST 2005
Bryan Olson wrote:
> Steven Bethard wrote:
> > Well, I couldn't find where the general semantics of a negative stride
> > index are defined, but for sequences at least:
> > "The slice of s from i to j with step k is defined as the sequence of
> > items with index x = i + n*k such that 0 <= n < (j-i)/k."
> > This seems to contradict list behavior though. [...]
> The conclusion is inescapable: Python's handling of negative
> subscripts is a wart.
I'm not sure I'd go that far. Note that my confusion above was the
order of combination of points (3) and (5) on the page quoted above.
I think the problem is not the subscript handling so much as the
documentation thereof. I posted a message about this , and a
documentation patch based on that message .
> Suppose instead of using semicolons as the PPEP proposes, we use
> commas, as in:
> sequence[start, stop, step]
This definitely won't work. This is already valid syntax, and is used
heavily by the numarray/numeric folks.
More information about the Python-list