[SciPy-user] Array Bounds
Robert Kern
robert.kern at gmail.com
Fri Mar 9 13:07:27 EST 2007
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?
It is a consequence of *Python* using zero-indexing everywhere. numpy simply
follows suit. It means that range(len(sequence)) gives you all of the indices
into sequence.
Just give it some time. You will grow used to it.
> In case
> one should not like it, can it be changed by the user?
No.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list