>>> x = range(20)
>>> s = slice(None,None,2)
>>> x[s]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: sequence index must be integer, not 'slice'
Well, it has the same behaviour as the iterator returned by xrange in
Python 2.X - so expected I guess. The error message is also the same
in Python 2.X.
Michael Foord
--
http://www.ironpythoninaction.com/
range is an iterator now. Try itertools.islice.
Well yes, it behaves like xrange did.
But (also like xrange) it supports indexing. (!)
So why not slicing?
I expected this (to keep it functionally
more similar to the old range).
Alan Isaac
The old range function returned a list. If you need the old
functionality you can use list(range(...))[].
Why do you want to slice a range anyway? The range type supports a
start, stop and step argument.
Christian