[Python-Dev] Ranges

Paul Prescod paul@prescod.net
Wed, 12 Jul 2000 15:03:29 -0500

Ka-Ping Yee wrote:
>     >>> [0,1,2,3,4,5,6,7,8,9,10][0:5:2]
>     [0, 2, 4]

Well, today this is syntactically correct but it doesn't work as you (or
I) predict. I don't know if that's because nobody has implemented it yet
or if extended slices mean something other than what I think you and I
think they should mean:

Python 2.0b1 (#12, Jul  1 2000, 13:14:33)
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
Copyright 1995-2000 Corporation for National Research Initiatives (CNRI)
>>> [0,1,2,3,4,5,6,7,8,9,10][0:5:2]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: sequence index must be integer

The documentation on extended slicing is very thin, but if it doesn't do
this, I'm not sure what it does!

 Paul Prescod - Not encumbered by corporate consensus
Simplicity does not precede complexity, but follows it. 
	- http://www.cs.yale.edu/~perlis-alan/quotes.html