On 4/29/07, Andrew Straw <strawman@astraw.com> wrote:
No, the nth index of a Python sequence is a[n], where n starts from
zero. Thus, if I want the nth dimension of array a, I want a.shape[n].

I reverted the page to its original form and added a couple explanatory
comments about zero vs one based indexing.


<pedantic sounding rant -- apologies in advance>
Those among us who value correct English will continue to insist that ordinal numbers begin with "first" and the concept of "zeroth" is an unnatural technological bastardization.  (This is not to say that zero-based indexing is bad -- just distinct from the ordinal.)

The first index of 'a' is 0, the first element is a[0], the second index is 1 and the second element is a[1], etc.  Thus, the n-th index or element, a contraction of ordinal numbering, is correctly and canonically written as a[n-1] in a zero-based index scheme.  The linguistics of "n-th" are that of ordinality in both English and mathematics, requiring an explicitly mapping to the technological concept of a given indexing syntax. 

Glossing over that difference, especially when it contradicts the most natural conventions of the target audience, is unfriendly and counterintuitive.  The only reason why it makes sense to you only because of your disadvantage of already understanding that which you are trying to explain.
</pedantic sounding rant>

My recommendation: keep a[n-1] _and_ include a lucid discussion on zero-based indexing.

Pedantically,
-Kevin

 

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion