[BangPypers] which is better solution of the question

Srijayanth Sridhar srijayanth at gmail.com
Wed Jun 17 12:45:52 CEST 2009


On Wed, Jun 17, 2009 at 1:57 PM, Anand Balachandran Pillai <
abpillai at gmail.com> wrote:

>
>
> On Wed, Jun 17, 2009 at 12:54 PM, Anand Chitipothu <anandology at gmail.com>wrote:
>
>> >
>> > Don't use sorted(..., reverse=True). Instead reverse the list in place
>> > by using reverse slicing of l[-1::-1], which is about 1.5 times faster.
>>
>> Why are you using [-1::-1] for reversing? Isn't [::-1] the python
>> idiom for reversing a list?
>
>
> I am used to [-1::-1] and "Explicit is better than implicit".
> [::-1] gives (at least to me) the impression that it is equal to [0::-1]
> which it is not.
>
>
>>
>> _______________________________________________
>> BangPypers mailing list
>> BangPypers at python.org
>> http://mail.python.org/mailman/listinfo/bangpypers
>>
>
>
>
> --
> -Anand
>
>
>
>
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers
>
>
As a python newbie, I find this a bit annoying. It would be nicer to have a
simple reverse method in the str class.

name="The world according to Garp"
# name.reverse() or str.reverse(name) sure beats the hell out of
name[-1::-1] or name[::-1]

Jayanth
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/bangpypers/attachments/20090617/2d9fdf1c/attachment.htm>


More information about the BangPypers mailing list