On Aug 21, 2011 1:34 PM, Max maxmo...@gmail.com 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
On Aug 20, 1:40 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info 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 maxmo...@gmail.com wrote:
On Sun, Aug 21, 2011 at 10:27 AM, Max maxmo...@gmail.com wrote:
On Aug 20, 1:40 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz maxmo...@gmail.com wrote:
Would it be a good idea to change Python definition so that a[10, -1, -1]
I
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?
This would require disabling the negative stop value means counting from
the end of the array magic whenever the step value is negative.
The
On Sat, Aug 20, 2011 at 7:20 PM, Max Moroz maxmo...@gmail.com 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
On Aug 20, 11:29 am, Chris Angelico ros...@gmail.com 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
On Sat, Aug 20, 2011 at 7:52 PM, Max maxmo...@gmail.com 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
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 maxmo...@gmail.com 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