On Apr 23, 1:38 pm, Antoon Pardon <[EMAIL PROTECTED]> wrote: > The following is part of the explanation on slices in the > tutorial: > > The best way to remember how slices work is ... > +---+---+---+---+---+ > | H | e | l | p | A | > +---+---+---+---+---+ > 0 1 2 3 4 5 > -5 -4 -3 -2 -1 > > This is all very well with a simple slice like: > > "HelpA"[2:4] => "lp" > > But it give the wrong idea when using the following extended slice: > > "HelpA"[4:2:-1] => "Ap"
I think that the tutorial example is absolutely fine as it is. It gives the new python programmer (the target demographic of the tutorial) a visual tool to understand what simple slicing is. Extended slicing (in particular ones using negative indices) are beyond the scope of the tutorial, and thus are irrelevant as far as the example goes. Adding examples / memory aids to cover all the many varied and possibly degenerate ways you can slice a string would merely confuse the python newbie. By the time you actually *are* interested in the more advanced slicing capabilities, it's time to read the Library reference where the formula stating *exactly* how slicing works is stated. A tutorial has every reason to be simplistic, so as far as I'm concerned, -1 for changing the docs. Apologies if this turns out to be my third near identical post - I've tried sending variations on this message twice already today from Google Groups, and they seem to have got lost in the ether... -- http://mail.python.org/mailman/listinfo/python-list