[SciPy-user] array indexing

Yann Le Du yann.ledu at noos.fr
Fri Jan 24 13:26:47 EST 2003


On Fri, 24 Jan 2003, Agustin Lobo wrote:

> 
> 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 ?

That's the way indexing works in Python : you can understand it by looking 
at 0 and 2 inside [0:2] as meaning "from separator 0 to separator 2", 
where the separators are the things that separate the array values from 
one another : see 
http://www.python.org/doc/current/tut/node5.html#SECTION005140000000000000000

Yann




More information about the SciPy-User mailing list