Nice way to cast a homogeneous tuple
Nick Raptis
airscorp at otenet.gr
Wed Jul 28 09:31:14 EDT 2010
Ep, that missing line should be:
On 07/28/2010 04:27 PM, Nick Raptis wrote:
> On 07/28/2010 04:15 PM, wheres pythonmonks wrote:
>>
>> f( *map(lambda x: int(x), struct.unpack('2s2s2s','123456')))
>> 102
>>
>> But this seems too complicated.
>>
>>
> Well, you don't need the lambda at all
> int === lambda x: int(x)
>
> So just write
>
f( *map(int, struct.unpack('2s2s2s', '123456')))
Pretty compact now, isn't it?
> It's like writing:
> def myint(x):
> return int(x)
>
>
> Nick,
>
> Warm thanks to Steven D' Aprano who taught me that just yesterday in
> the Tutor list ;)
More information about the Python-list
mailing list