[issue3004] Bug in slice.indices()

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


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

On Wed, Jun 18, 2008 at 4:56 PM, Arnaud Bergeron <report at bugs.python.org>
wrote:

>
> Arnaud Bergeron <abergeron at gmail.com> added the comment:
>
> Would these do?
>
> self.assertEqual(slice(None,   -10    ).indices(10), (0,  0,  1))
> self.assertEqual(slice(None,   -11,   ).indices(10), (0,  0,  1))
> self.assertEqual(slice(None,   -12, -1).indices(10), (9, -1, -1))
>

Perfect.  Thank you.

If this is changed, then I think the following should also be
changed:

(9, 10, -1)

I believe the second index here should be 9, not 10.
Do you agree?

With these two changes the code, while marginally
more complicated, is actually easier to understand than
before, since exactly the same processing is applied
to both the start and stop indices.  I think this is as
it should be.

Added file: http://bugs.python.org/file10669/unnamed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3004>
_______________________________________
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: unnamed
URL: <http://mail.python.org/pipermail/python-bugs-list/attachments/20080620/0ff0434a/attachment.txt>


More information about the Python-bugs-list mailing list