[SciPy-user] Array Bounds

Jerry lanceboyle@qwest....
Fri Mar 9 18:56:19 CST 2007


On Mar 9, 2007, at 8:57 AM, Lorenzo Isella wrote:

> Dear All,
> Again a newbie question: I noticed that Python (or at least
> Numpy/Scipy) follows the C convention of labeling as zero the first
> element in an array.
> I can live with this, but I do not find very intuitive the loop  
> behavior:
>
> for i in range (1,5 )
>
> means that i actually takes values 1,2,3,4 and not 5!
> Why this choice? Is it a consequence of the array labeling? In case
> one should not like it, can it be changed by the user?
> Kind Regards
>
> Lorenzo

In my opinion, this is poor language design (along with Henry Ford- 
style array indexing--any array you want as long as it starts with  
zero) and an impediment to writing correct programs. Good design lets  
the programmer abstract his program to resemble the real-world  
problem that he is working on. Get used to it or move along--every  
time I post about this, that's the advice I get. (1) Python arrays  
will _never_ change; (2) it is blasphemous to even mention it; (3)  
someone will ask, why in the world would anyone want an array that  
doesn't start with zero; (4) someone will flame me.

Jerry



More information about the SciPy-user mailing list