negative stride list slices

Julio Oña thinmanj at gmail.com
Wed Sep 1 17:31:09 EDT 2004


http://www.python.org/doc/2.3.4/whatsnew/section-slices.html

There is more information on extended slicing

Regards.

On Wed, 1 Sep 2004 17:23:18 -0400, Julio Oña <thinmanj at gmail.com> wrote:
> Slice has three arguments, [begin:end:step]
> 
> when doing s[:-3:-1] you are asking the las to elements of the list in
> reversed order.
> 
> regards.
> 
> 
> 
> On Wed, 01 Sep 2004 17:15:51 -0400, Peter Hansen <peter at engcorp.com> wrote:
> > Reid Nichol wrote:
> >
> > > This was the part that I was refering to:
> > >
> > >  +---+---+---+---+---+
> > >  | H | e | l | p | A |
> > >  +---+---+---+---+---+
> > >  0   1   2   3   4   5
> > > -5  -4  -3  -2  -1
> > >
> > > Does it not all work the same in practice?
> >
> > Can you explain how the above diagram explains David's
> > example then:
> >
> > >>> s = 'HelpA'
> > >>> s[:-3:-1]
> > 'Ap'
> >
> > I don't find much connection between the diagram and
> > where the -3 is actually slicing either.
> >
> > -Peter
> >
> >
> > --
> > http://mail.python.org/mailman/listinfo/python-list
> >
> 
> 
> --
> Julio
> 


-- 
Julio



More information about the Python-list mailing list