Re: slice with negative stride

2007-10-06 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: >>> mystr = 'my string' > > I would have then thought of the contents of mystr as: > > indices0 1 2 3 4 5 6 7 8 > contentm y s t r i n g > > with mystr[:3] = 'my ' > > Can someone explain to me how mystr[:3:-1] = 'gnirt'? A slice [i:j:k] includes the first i

Re: slice with negative stride

2007-10-06 Thread Mark T
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I'm really confused about results of slices with negative strides. For > example > >>>mystr = 'my string' > > I would have then thought of the contents of mystr as: > > indices0 1 2 3 4 5 6 7 8 > contentm y s t r i n g > > wi

Re: slice with negative stride

2007-10-06 Thread Paul Hankin
On Oct 6, 1:05 pm, [EMAIL PROTECTED] wrote: > I'm really confused about results of slices with negative strides. For > example > > >>mystr = 'my string' > ... > Can someone explain to me how mystr[:3:-1] = 'gnirt'? You've omitted the first number in the slice: python uses a sensible default for it

slice with negative stride

2007-10-06 Thread ajcppmod
I'm really confused about results of slices with negative strides. For example >>mystr = 'my string' I would have then thought of the contents of mystr as: indices0 1 2 3 4 5 6 7 8 contentm y s t r i n g with mystr[:3] = 'my ' Can someone explain to me how mystr[:3:-1] = 'gnirt'? I