Extended slice notation doesn't recognise integer

Paul Prescod paul at prescod.net
Sun Feb 8 15:46:20 EST 2004


Thomas Covello wrote:

> Why does the following code give this error:
> 
>>>>[0, 1, 2, 3, 4][::2]
> 
> TypeError: sequence index must be integer

In Python 2.2 lists did not support extended slice notation but in 2.3 
they do.

Python 2.3.2 (#4, Feb  2 2004, 00:30:40)
[GCC 3.1 20020420 (prerelease)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> [0, 1, 2, 3, 4][::2]
[0, 2, 4]

http://www.python.org/peps/pep-0283.html
"This document describes the development and release schedule for Python 
2.3."

"Extended slice notation for all built-in sequences.  The patch by 
Michael Hudson is now all checked in."

  Paul Prescod






More information about the Python-list mailing list