Tutorial creates confusion about slices

Antoon Pardon apardon at forel.vub.ac.be
Wed Apr 25 06:46:42 EDT 2007


On 2007-04-25, Ant <antroy at gmail.com> wrote:
> On Apr 23, 1:38 pm, Antoon Pardon <apar... at forel.vub.ac.be> wrote:
>> The following is part of the explanation on slices in the
>> tutorial:
>>
>> The best way to remember how slices work is to think of the indices as
> ...
>>   +---+---+---+---+---+
>>   | H | e | l | p | A |
>>   +---+---+---+---+---+
>>   0   1   2   3   4   5
>>  -5  -4  -3  -2  -1
>
> For a tutorial this is sound advice. A tutorial is designed to give
> readers an easy intro to a topic, which is what this achieves. At this
> stage the target audience has no idea that extended slices even exist,
> let alone that you can use negative indices with them.

OK. But eventually they will come into contact with negative indexes.
If they still rely on the above representation for understanding slices
that may cause confusions. It is possible that the time lost in clearing
up these later confusions will be bigger than the time gained by using
this simplification in the tutorial.

So I'm not so sure it is sound advice in this case.

If the consensus is that something like this should remain, I would
suggest replacing:

    "The best way to remember how slices work is"

with:

    "A way to remember how slices work, it is not entirly correct
     but may be usefull, is"

Or something similar.


Wording to that effect makes it more clear that it is a crutch
that can be usefull now but that it should be discarded later.

-- 
Antoon Pardon



More information about the Python-list mailing list