tuple to string?
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Sat Jul 23 22:30:26 EDT 2005
On Sat, 23 Jul 2005 23:26:19 +1000, John Machin wrote:
> Steven D'Aprano wrote:
>
>>
>>
>>>>>''.join(map(lambda n: chr(n), (0x73, 0x70, 0x61, 0x6D)))
>>
>> 'spam'
>
> Why the verbal diarrhoea?
One line is hardly verbal diarrhoea.
> What's wrong with the (already posted)
>
> ''.join(map(chr, (0x73, 0x70, 0x61, 0x6D)))
>
> ???
Nothing.
If I had seen the already posted solution using chr on its own without
lambda, I wouldn't have bothered posting the lambda solution. But I
didn't, so I did.
As another poster has already pointed out, lambda cries out for over-use,
and this was a perfect example of it.
--
Steven.
More information about the Python-list
mailing list