[SciPy-user] array indexing

Travis Oliphant oliphant at ee.byu.edu
Mon Jan 27 11:30:14 EST 2003


> Why is this?
>
> >>> t
> array([0, 1, 2, 3])
> >>> t[0:2]
> array([0, 1])
>
> Why is not
> array([0,1,2]) ? Am I not asking
> for positions 0,1 and 2 in t ?

Now, array slicing follows the same syntax as Python itself.  Namely, the
last index is not included.  You are requesting positions 0 and 1 only
with your slice notation t[0:2]

-Travis O.





More information about the SciPy-User mailing list