Python "why" questions

Steven D'Aprano steve at
Sat Aug 21 10:33:26 CEST 2010

On Fri, 20 Aug 2010 11:01:42 -0700, Russ P. wrote:

> Most programmers probably never use vectors and matrices, so they don't
> care about the inconsistency with standard mathematical notation.

Perhaps you should ask the numpy programmers what they think about that.

Vectors and matrices are just arrays, and the suggestion that most 
programmers don't use arrays (or array-like objects like lists) is 

> And yes, I understand that zero-based indexing can be slightly more
> efficient. That's why I think it's appropriate for low-level languages
> such as C. However, I think one-based indexing is more appropriate for
> high-level languages.

Only if your aim is to reduce the learning curve for newbies and non-
programmers, at the expense of making it easier for them to produce buggy 

That's a defensible choice. I'm a great fan of Apple's Hypercard from the 
late 80s and early 90s, and it used one-based indexing, as well as 
English-like syntax like:

put char 2 of the third word of it into the last field

You don't need to know a thing about the language to guess what that 
does, and you'd probably be right. It would have been inappropriate for 
Hypercard to use zero-based indexing, because it was aimed at giving non-
programmers a shallow learning curve and syntax that looks like natural 

There is room in the world for programming languages aimed at non-
programmers (although HC is an extreme case), but not all languages 
should prefer the intuition of non-programmers over other values.


More information about the Python-list mailing list