[Python-ideas] Where did we go wrong with negative stride?

אלעזר elazarg at gmail.com
Fri Nov 1 14:26:32 CET 2013


2013/11/1 Oscar Benjamin <oscar.j.benjamin at gmail.com>:
> On 1 November 2013 10:17, Steven D'Aprano <steve at pearwood.info> wrote:
>> To break the ambiguity, we'd need a rule that End objects can only occur
>> inside slices with at least one colon.
>
> This would defeat much of the point of having a new notation. The
> problem with negative wraparound applies just as much to ordinary
> indexing as to slicing.
>
Not exactly as much. taking

    x[:-0] # intention: x[:len(x)]

is a reasonable, which happens to fail in Python. While

    x[-0]  # intention: x[len(x)]

is an error in the first place, which happens not to raise an
Exception in Python, but rather gives you a wrong result.

Elazar


More information about the Python-ideas mailing list