Why Python does *SLICING* the way it does??

Torsten Bronger bronger at physik.rwth-aachen.de
Wed Apr 20 11:52:18 EDT 2005


Hallöchen!

Bernhard Herzog <bh at intevation.de> writes:

> Torsten Bronger <bronger at physik.rwth-aachen.de> writes:
>
>> It's interesting to muse about a language that starts at "1" for
>> all arrays and strings, as some more or less obsolete languages
>> do.  I think this is more intuitive, since most people (including
>> mathematicians) start counting at "1".  The reason for starting
>> at "0" is easier memory address calculation, so nothing for
>> really high level languages.
>
> There are very good reasons for half-open intervals and starting
> at 0 apart from memory organization.  Dijkstra explained this
> quite well in
> http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF

I see only one argument there: "Inclusion of the upper bound would
then force the latter to be unnatural by the time the sequence has
shrunk to the empty one."  While this surely is unaesthetical, I
don't think that one should optimise syntax according to this very
special case.  Besides, no language I know of has probems with
negative values.

Well, and the argument for "0" derives from that, according to
Dijkstra.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus



More information about the Python-list mailing list