Composition of functions
Stephen Hansen
me+list/python at ixokai.io
Thu Jul 1 03:54:40 EDT 2010
On 7/1/10 12:45 AM, Terry Reedy wrote:
> On 7/1/2010 12:32 AM, Mladen Gogala wrote:
>> On Wed, 30 Jun 2010 21:04:28 -0700, Stephen Hansen wrote:
>
>>> However, you can easily get what you want by using the 'reversed'
>>> function (and similarly, the 'sorted' function), a la:
>>>
>>> >>> y = ''.join(reversed(list(x)))
>>>
>>> The 'reversed' and 'sorted' functions are generators that lazilly
>>> convert an iterable as needed.
>>
>> Ah, that is even better. Thanks.
>
> It is better if you do not mind making an unnecessary copy. If the list
> had 10 million elements, you might prefer your original.
The original that did not work? :)
--
... Stephen Hansen
... Also: Ixokai
... Mail: me+list/python (AT) ixokai (DOT) io
... Blog: http://meh.ixokai.io/
More information about the Python-list
mailing list