Python 3: range objects cannot be sliced

Alan G Isaac alan.isaac at gmail.com
Fri Jan 16 12:45:21 EST 2009


Is the behavior below expected? Documented?
(The error msg is misleading.)
Thanks,
Alan Isaac

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



More information about the Python-list mailing list