Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Georg Brandl
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['

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Jonathan Gardner
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

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread SMB
"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

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Gerard Flanagan
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: > >>

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Dave Hansen
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

Re: Merging two lists of data (Pythonic way)

2006-02-17 Thread Steven D'Aprano
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

Re: Merging two lists of data (Pythonic way)

2006-02-16 Thread Lonnie Princehouse
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

Re: Merging two lists of data (Pythonic way)

2006-02-16 Thread Paul Rubin
"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

Re: Merging two lists of data (Pythonic way)

2006-02-16 Thread SMB
"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