Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #57899

Re: Slicing with negative strides

From Terry Reedy <tjreedy@udel.edu>
Subject Re: Slicing with negative strides
Date 2013-10-29 06:21 -0400
References <526f45f8$0$6512$c3e8da3$5496439d@news.astraweb.com> <XnsA26858FD6F7E7duncanbooth@127.0.0.1>
Newsgroups comp.lang.python
Message-ID <mailman.1753.1383042093.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 10/29/2013 4:53 AM, Duncan Booth wrote:
> Steven D'Aprano <steve@pearwood.info> wrote:
>
>> Does anyone here use slices (or range/xrange) with negative strides
>> other than -1?
>>
>> E.g. sequence[2:15:-3]
>
> With any negative stride your example is just the empty sequence.

The idea is that one would not have to reverse 2 and 15 to get a 
non-empty sequence.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Slicing with negative strides Steven D'Aprano <steve@pearwood.info> - 2013-10-29 05:22 +0000
  Re: Slicing with negative strides Duncan Booth <duncan.booth@invalid.invalid> - 2013-10-29 08:53 +0000
    Re: Slicing with negative strides Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-29 09:34 +0000
    Re: Slicing with negative strides Terry Reedy <tjreedy@udel.edu> - 2013-10-29 06:21 -0400
    Re: Slicing with negative strides Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-10-29 11:04 +0000
  Re: Slicing with negative strides Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-10-29 08:54 +0000
  Re: Slicing with negative strides Martin Manns <mmanns@gmx.net> - 2013-11-04 00:15 +0100
    Re: Slicing with negative strides Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-04 15:18 +0000
  Re: Slicing with negative strides Peter Cacioppi <peter.cacioppi@gmail.com> - 2013-11-06 11:15 -0800

csiph-web