Python 3: range objects cannot be sliced
Christian Heimes
lists at cheimes.de
Fri Jan 16 13:57:47 EST 2009
Alan G Isaac schrieb:
> On 1/16/2009 1:15 PM Paul Rubin apparently wrote:
>> 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).
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
More information about the Python-list
mailing list