What is :: (double colon) in numpy like in myarray[0::3]?

Question:

Possible Duplicate:
What is :: (double colon) in Python?

I read the question What is :: (double colon) in Python when subscripting sequences?, but this not answer what myarray[x::y] mean.

Asked By: Framester

||

Answers:

It prints every yth element from the list / array

>>> a = [1,2,3,4,5,6,7,8,9]
>>> a[::3]
[1, 4, 7]

The additional syntax of a[x::y] means get every yth element starting at position x

ie.

>>> a[2::3]
[3, 6, 9]
Answered By: GWW
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.