G
GavinCrooks
The indices method of slice doesn't seem to work quite how I would
expect when reversing a sequence.
For example :
So a slice with a negative step (and nothing else) reverses the
sequence. But what are the
corresponding indices?(4, -1, -1)
That looks O.K. The start is the last item in the sequence, and the
stop is one before the beginning of the sequence. But these indices
don't reverse the string:
Although they give the correct range:[4, 3, 2, 1, 0]
It would appear that there is no set of indices that will both reverse
the string and produce the correct range!
Is this a bug or a feature?
GEC
See also: http://www.python.org/doc/2.3.5/whatsnew/section-slices.html
expect when reversing a sequence.
For example :
'43210's = '01234'
s[::-1] '43210'
s[slice(None,None,-1) ]
So a slice with a negative step (and nothing else) reverses the
sequence. But what are the
corresponding indices?(4, -1, -1)
That looks O.K. The start is the last item in the sequence, and the
stop is one before the beginning of the sequence. But these indices
don't reverse the string:
''
Although they give the correct range:[4, 3, 2, 1, 0]
It would appear that there is no set of indices that will both reverse
the string and produce the correct range!
Is this a bug or a feature?
GEC
See also: http://www.python.org/doc/2.3.5/whatsnew/section-slices.html