[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 
must
evaluate to a mapping object, and it is indexed with a key that is 
constructed
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; 
otherwise,
the conversion of the lone slice item is the key. The conversion of a 
slice
item that is an expression is that expression. The conversion of an 
ellipsis
slice item is the built-in Ellipsis object. The conversion of a proper 
slice
is a slice object (see section 3.2) whose start, stop and step 
attributes
are the values of the expressions given as lower bound, upper bound 
and
stride, respectively, substituting None for missing expressions.
-----------------------

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

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

:-)

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld






More information about the Tutor mailing list