Python "why" questions

John Nagle nagle at animats.com
Sat Aug 7 15:14:46 EDT 2010


On 8/7/2010 5:00 AM, Thomas Jollans wrote:
> On 08/07/2010 05:05 AM, Default User wrote:
>> > From "the emperor's new clothes" department:
>>
>> 1)  Why do Python lists start with element [0], instead of element [1]?
>> "Common sense" would seem to suggest that lists should start with [1].
>
> As others have pointed out, there is a nice argument to be made for
> zero-based indices. However, the killer reason is: "it's what everybody
> else does."

    FORTRAN, MATLAB, and Octave all use 1-based subscripts.

    The languages which have real multidimensional arrays, rather
than arrays of arrays, tend to use 1-based subscripts.  That
reflects standard practice in mathematics.

					John Nagle



More information about the Python-list mailing list