[Python-Dev] [issue5029] Odd slicing behaviour

Lambert, David W (S&T) LambertDW at Corning.com
Thu Jan 22 21:29:09 CET 2009

I cannot find that the documentation states "with negative step swap
left with right".  This is perhaps non-obvious.  It is the words of the
tutorial that caused issue 5029 author's confusion.  'a'[0::-1] != []
(is True, author expected False).
The tutorial says:

"One way to remember how slices work is to think of the indices as
pointing between characters, with the left edge of the first character
numbered 0. Then the right edge of the last character of a string of n
characters has index n, for example:"

More information about the Python-Dev mailing list