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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Nov 1 22:45:36 CET 2013


אלעזר wrote:
>     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.

Using x[End-n] would allow an exception to be properly
raised when n is out of bounds instead of spuriously
wrapping around.

-- 
Greg


More information about the Python-ideas mailing list