[issue3004] Bug in slice.indices()

Mark Dickinson report at bugs.python.org
Fri Jun 20 12:52:59 CEST 2008


Mark Dickinson <dickinsm at gmail.com> added the comment:

> 0 <= start <= stop <= length    if step is positive, and
> length-1 >= start >= stop >= -1 if step is negative.

That should be:

0 <= start <= length and 0 <= stop <= length  (step > 0), and
length-1 >= start >= -1, length-1 >= stop >= -1 (step < 0);

it's not guaranteed that start <= stop always holds in the first case,
or that start >= stop in the second.

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3004>
_______________________________________


More information about the Python-bugs-list mailing list