Merging two lists of data (Pythonic way)
Dave Hansen
iddw at hotmail.com
Thu Feb 16 16:13:28 EST 2006
On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, "SMB"
<sean at buildingonline.com> wrote:
>
>"Jonathan Gardner" <jgardner at jonathangardner.net> wrote in message
>news:1140122391.823206.74580 at g14g2000cwa.googlegroups.com...
>> codes = map(lambda x: x[0], list1)
>> for d in list2:
>> if d['code'] in codes:
>> d['VERIFIED'] = 1
>>
>> Is this what you were looking for?
>>
>
>That is exactly what I was looking for. I will have to take a look at map.
You might also look at list comprehensions. Replacing the first line
in the above with
codes = [x[0] for x in list1]
should yield the same result.
Regards,
-=Dave
--
Change is inevitable, progress is not.
More information about the Python-list
mailing list