Nice way to cast a homogeneous tuple

Nick Raptis airscorp at otenet.gr
Wed Jul 28 09:27:58 EDT 2010


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

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