On Aug 21, 2011 1:34 PM, "Max" wrote:
> > a[0:11][::-1]
> > # Instead of a[10:-1:-1], which looks like it should work, but doesn't.
>
> It works nicely, but it is 1.3 times slower in my code (I am surprised
> the interpreter doesn't optimize this).
Have you tried reverse()? I haven't timed it, bu
On Sun, Aug 21, 2011 at 10:27 AM, Max wrote:
> On Aug 20, 1:40 pm, Steven D'Aprano +comp.lang.pyt...@pearwood.info> wrote:
>> On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz wrote:
>> > Would it be a good idea to change Python definition so that a[10, -1, -1]
>>
>> I presume you mean slice notation a
On Aug 20, 1:40 pm, Steven D'Aprano wrote:
> Pardon me for breaking threading, but I don't have Max's original post.
Not sure why; I also can't see it! I'll copy it at the end just in
case.
> On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz wrote:
> > Would it be a good idea to change Python definiti
Pardon me for breaking threading, but I don't have Max's original post.
On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz wrote:
> Would it be a good idea to change Python definition so that a[10, -1, -1]
I presume you mean slice notation a[10:-1:-1].
> referred to the elements starting with positio
On Sat, Aug 20, 2011 at 7:52 PM, Max wrote:
> That doesn't work if it's set in a loop or if it's calculated as a
> formula. For example, this very simple code doesn't work because of
> the "-1 problem".
>
Right, which is what I meant by setting it to an explicit None:
if input[starting_pos:endin
On Aug 20, 11:29 am, Chris Angelico wrote:
> If you're using a variable for the stop value, you just need to set it
> to an explicit None if it would fall negative:
>
> >>> a[10:None:-1]
>
That doesn't work if it's set in a loop or if it's calculated as a
formula. For example, this very simple co
On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz wrote:
> Would it be a good idea to change Python definition so that a[10, -1, -1]
> referred to the elements starting with position 10, going down to the
> beginning?
Well, first off I think it's a dangerous idea to change semantics of
something like th