[Tutor] What exactly is [::-1]?

Alan Gauld alan.gauld at btinternet.com
Thu Jul 26 09:24:26 CEST 2007

"wesley chun" <wescpy at gmail.com> wrote

> when you use the 3rd element, it's called the extended slice syntax.

The ref manual describes use of the third value as simple slicing,
for extended slicing it says this:

 The semantics for an extended slicing are as follows. The primary 
evaluate to a mapping object, and it is indexed with a key that is 
from the slice list, as follows. If the slice list contains at least 
one comma,
the key is a tuple containing the conversion of the slice items; 
the conversion of the lone slice item is the key. The conversion of a 
item that is an expression is that expression. The conversion of an 
slice item is the built-in Ellipsis object. The conversion of a proper 
is a slice object (see section 3.2) whose start, stop and step 
are the values of the expressions given as lower bound, upper bound 
stride, respectively, substituting None for missing expressions.

I've read it three times now and stioll have no idea what its on 

Some ex[erimentation needed I think, but no time now.


Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list