On Tue, Jun 16, 2009 at 9:35 AM, Anand Chitipothu wrote:
>> The zip solution is succinct.
>>
>> Also, by the virtue of being a built-in function zip() should be
>> faster than the second approach.
>
> Complexity of first solution is O(n)
> values, items = list(zip(*sorted(zip(values,items), revers
On Wed, Jun 17, 2009 at 7:14 PM, Srijayanth Sridhar wrote:
> On Wed, Jun 17, 2009 at 7:11 PM, Anand Chitipothu wrote:
>
>> > If you don't like s[::-1], then the closest would be
>> > ''.join([item for item in reversed(s)]), but that ain't close enough :)
>>
>
> I don't hate it enough to not use i
On Wed, Jun 17, 2009 at 7:11 PM, Anand Chitipothu wrote:
> > If you don't like s[::-1], then the closest would be
> > ''.join([item for item in reversed(s)]), but that ain't close enough :)
>
I don't hate it enough to not use it. I am just saying it from a perspective
of readability I suppose. C
> If you don't like s[::-1], then the closest would be
> ''.join([item for item in reversed(s)]), but that ain't close enough :)
No, the closest would be
"".join(reversed(s))
___
BangPypers mailing list
BangPypers@python.org
http://mail.python.org/mailm
On Wed, Jun 17, 2009 at 4:15 PM, Srijayanth Sridhar wrote:
>
>
>>
> 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
On Wed, Jun 17, 2009 at 1:57 PM, Anand Balachandran Pillai <
abpil...@gmail.com> wrote:
>
>
> On Wed, Jun 17, 2009 at 12:54 PM, Anand Chitipothu
> 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
On Wed, Jun 17, 2009 at 12:54 PM, Anand Chitipothu 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 rev
>
> 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?
___
BangPyp