Python "why" questions

Thomas Jollans thomas at jollans.com
Fri Aug 13 13:14:44 EDT 2010


On 2010-08-13 17:27, Den wrote:
> There may be loads of reasons for it, but don't throw common sense
> around as one of them.
>   

It's a good thing then that I didn't:

>> ... However, the killer reason is: "it's what everybody
>> else does.
>>     
>

"Where it all started" is that 0-based indexing gives languages like C a
very nice property: a[i] and *(a+i) are equivalent in C. From a language
design viewpoint, I think that's quite a strong argument. Languages
based directly on C (C++, Objective C, ...) can't break with this for
obvious reasons, and other language designers/implementers imitated this
behaviour without any good reason to do so, or not to do so. In
higher-level languages, it doesn't really matter. 1-based indexing might
seam more intuitive, but in the end, it's just another thing you have to
learn when learning a language, like "commas make tuples", and somebody
studying a programming language learns it, and gets used to it if they
aren't used to it already.



More information about the Python-list mailing list