"André" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>Terry Reedy wrote:
>> It appears that s[i:j:-1] is s[(j+1):(i+1)] .reverse()'ed. For
>> 'numbers',
>> this is 10, 9, 8, 7, 6, 5, 4, 3, 2]. Then take every other item. Why
>> the
>> +1? Don't know and not my intuitive expe
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
I've filed a bug report:
http://bugs.python.org/1446619
I suggest the following rewording for extended slices:
"""
To get the sli
Terry Reedy wrote:
> > John Salerno wrote:
> >> Given:
> > > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> > > can someone explain to me why
> > > numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
>
> It appears that s[i:j:-1] is s[(j+1):(i+1)] .reverse()'ed. For 'numbers',
> this is 10, 9, 8, 7, 6, 5,
> John Salerno wrote:
>> Given:
> > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> > can someone explain to me why
> > numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
It appears that s[i:j:-1] is s[(j+1):(i+1)] .reverse()'ed. For 'numbers',
this is 10, 9, 8, 7, 6, 5, 4, 3, 2]. Then take every other i
André wrote:
> An extended slice of list x of length n in the form x[j:k:i] selects
> every i-th element starting with and including the element at index j
This makes it sound like the index of 10 should be inclusive.
> When either index is missing or lies outside of the
> list bounds, the mini
Steven D'Aprano wrote:
> John Salerno wrote:
>
> > Given:
> >
> > numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> >
> > can someone explain to me why
> >
> > numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
>
> I think the documentation is misleading/incomplete when
> it comes to negative strides for ext
John Salerno wrote:
> James Stroud wrote:
>
>> John Salerno wrote:
>>
>>> Given:
>>>
>>> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>>
>>> can someone explain to me why
>>>
>>> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
>>>
>>> I thought the first index, whether going forward or backward, was
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
I think the documentation is misleading/incomplete when
it comes to negative strides for extended slices.
The relevent sections are h
James Stroud wrote:
> John Salerno wrote:
>> Given:
>>
>> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>
>> can someone explain to me why
>>
>> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
>>
>> I thought the first index, whether going forward or backward, was
>> inclusive. And there is no index of
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
I always have trouble with these. Given the docs[1]:
"""
The slice of s from i to j with step k is defined as the sequence of
items w
John Salerno wrote:
> Given:
>
> numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> can someone explain to me why
>
> numbers[10:0:-2] results in [10, 8, 6, 4, 2]?
>
> I thought the first index, whether going forward or backward, was
> inclusive. And there is no index of 10 in this list, so what is
11 matches
Mail list logo