[SciPy-user] Array Bounds

Alok Singhal as8ca@virginia....
Sat Mar 10 00:31:07 CST 2007

On 09/03/07: 22:59, Perry Greenfield wrote:
> Actually, your complaint is not directly due to that issue (though  
> it's related). As I read it, it's because you are surprised that the  
> end of the range does not include the number that's used for the end  
> of the range. And that's a natural enough reaction. It's not  
> intuitive to many people. But what's intuitive is not always the best  
> choice. It works that way (I'm guessing here) because slices in  
> Python work that way (e.g., mylist[1:5] doesn't include mylist[5]).  

It might also be (I am guessing too) because range(n) should,
intuitively, return n numbers.  Given 0-based indices, it makes (some)
sense to start the numbers at 0, and hence, stop at n-1.  So, then by
generalization, range(m,n) should generate integers m, m+1, .., n-1.
That is the least surprising result.


Alok Singhal                               *   *          
Graduate Student, dept. of Astronomy   *           *     *
University of Virginia                                    
http://www.astro.virginia.edu/~as8ca/              *    * 

More information about the SciPy-user mailing list