469,293 Members | 1,319 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,293 developers. It's quick & easy.

Extended slicing and Ellipsis - where are they used?

The following are apparently legal Python syntactically:
L[1:3, 8:10]
L[1, ..., 5:-2]

But they don't seem to work on lists:
>>l = [0,1,2,3]
l[0:2,3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers
>>l[...]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers

So where is this extended slicing used?

--
Rodney

Sep 13 '07 #1
1 1943
Rodney Maxwell wrote:
The following are apparently legal Python syntactically:
L[1:3, 8:10]
L[1, ..., 5:-2]

But they don't seem to work on lists:
>>>l = [0,1,2,3]
l[0:2,3]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers
>>>l[...]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: list indices must be integers

So where is this extended slicing used?
numpy for multidimensional arrays.

http://numpy.scipy.org/

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

Sep 13 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by Jerry Sievers | last post: by
17 posts views Thread by baibaichen | last post: by
3 posts views Thread by GavinCrooks | last post: by
2 posts views Thread by Rahul | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.