Possible improvement to slice opperations.
Patrick Maupin
pmaupin at gmail.com
Mon Sep 5 21:42:27 EDT 2005
> No one has yet explained the reasoning (vs the mechanics) of the
> returned value of the following.
>
> L = range(10)
> L[3::-1]
>
> So far every attempt to explain it has either quoted the documents which
> don't address that particular case, or assumed I'm misunderstanding
> something, or implied it isn't neccisary to do.
>
> It's quite easy to get me to change my mind on something, just show me a
> convincing explanation and I will. :)
Once I saw this, I was surprised, because slices currently work exactly
like I would and do expect on this example, so I now have to admit that
I didn't read your original post fully and carefully. I have gone back
to look to figure out what you don't like and what you want, and I am
very surprised.
To me, your way reeks of black magic -- if there is a sign on the
stride, then strange and wondrous transformations happen. I think it
is conceptually (and probably programatically) much simpler the way it
is.
In any case, you asked for a rationale. I'll give you mine:
>>> L = range(10)
>>> L[3:len(L):-1] == [L[i] for i in range(3,len(L),-1)]
True
>>>
If you manage somehow to hange that 'True' to a 'False', I'll
personally be extremely unhappy.
Regards,
Pat
More information about the Python-list
mailing list