Dave Hansen wrote:
> On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, "SMB"
> <[EMAIL PROTECTED]> wrote:
>
>>
>>"Jonathan Gardner" <[EMAIL PROTECTED]> wrote in message
>>news:[EMAIL PROTECTED]
>>> codes = map(lambda x: x[0], list1)
>>> for d in list2:
>>> if d['code'] in codes:
>>>d['
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?
--
http://mail.python.org/mailman/listinfo/python-list
"Jonathan Gardner" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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?
>
Actually, this is not exactly what I was looking for. I failed to reali
Dave Hansen wrote:
> On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, "SMB"
> <[EMAIL PROTECTED]> wrote:
>
> >
> >"Jonathan Gardner" <[EMAIL PROTECTED]> wrote in message
> >news:[EMAIL PROTECTED]
> >> codes = map(lambda x: x[0], list1)
> >> for d in list2:
> >> if d['code'] in codes:
> >>
On Thu, 16 Feb 2006 12:51:24 -0800 in comp.lang.python, "SMB"
<[EMAIL PROTECTED]> wrote:
>
>"Jonathan Gardner" <[EMAIL PROTECTED]> wrote in message
>news:[EMAIL PROTECTED]
>> codes = map(lambda x: x[0], list1)
>> for d in list2:
>> if d['code'] in codes:
>>d['VERIFIED'] = 1
>>
>> Is this wha
On Thu, 16 Feb 2006 12:30:47 -0800, SMB wrote:
> I know I could do this with two for loops, but am looking for a better
> solution maybe involving list comprehension.
What's wrong with for loops? Why do you think they are unPythonic?
--
Steven.
--
http://mail.python.org/mailman/listinfo/pyt
You might consider writing two classes to represent the values in list1
and list2. It might be more Pythonic than sloshing around all of those
lists and dictionaries.
But as it is, it looks like you want to find matching pairs of lists
and dictionaries from list1 and list2, respectively:
# index
"SMB" <[EMAIL PROTECTED]> writes:
> What I am doing is looking for a pythonic way to parse the LIST2 "code"
> values and make appropriate changes to to each dictionary if the "code"
> value is the first element of a list in LIST1.
>
> The final result may look like this given that the change is
"Jonathan Gardner" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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 m