Re: Pythonic search of list of dictionaries

2005-01-05 Thread Bulba!
On Tue, 04 Jan 2005 21:57:46 +0100, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >In <[EMAIL PROTECTED]>, Bulba! wrote: > >> I put those dictionaries into the list: >> >>oldl=[x for x in orig] # where orig=csv.DictReader(ofile ... > >If you don't "do" anything with each `x` you can wr

Re: Pythonic search of list of dictionaries

2005-01-04 Thread John Machin
Bulba! wrote: [big snip] Forget the csv-induced dicts for the moment, they're just an artifact of your first solution attempt. Whether english = csv_row[1], or english = csv_row_dict["english"], doesn't matter yet. Let's take a few steps back, and look at what you are trying to do through a telesc

Re: Pythonic search of list of dictionaries

2005-01-04 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Bulba! wrote: > I put those dictionaries into the list: > >oldl=[x for x in orig] # where orig=csv.DictReader(ofile ... If you don't "do" anything with each `x` you can write this as: oldl = list(orig) Ciao, Marc 'BlackJack' Rintsch -- http://mail.pyth

Re: Pythonic search of list of dictionaries

2005-01-04 Thread Scott David Daniels
Skip Montanaro wrote: ...lotsa great stuff ... You might want to sort your lists by the 'English' key. I don't know how to use the new key arg to list.sort(), but you can still do it the old-fashioned way: oldl.sort(lambda a,b: cmp(a['English'], b['English'])) newl.sort(lambda a,b: cmp(a['

Re: Pythonic search of list of dictionaries

2005-01-04 Thread Skip Montanaro
Bulba> I put those dictionaries into the list: Bulba>oldl=[x for x in orig] # where orig=csv.DictReader(ofile ... Bulba> ..and then search for matching source terms in two loops: Bulba>for o in oldl: Bulba>for n in newl: Bulba>if n['English']

Re: Pythonic search of list of dictionaries

2005-01-04 Thread Tim Hochberg
Bulba! wrote: Hello everyone, I'm reading the rows from a CSV file. csv.DictReader puts those rows into dictionaries. The actual files contain old and new translations of software strings. The dictionary containing the row data looks like this: o={'TermID':'4', 'English':'System Administration'

Pythonic search of list of dictionaries

2005-01-04 Thread Bulba!
Hello everyone, I'm reading the rows from a CSV file. csv.DictReader puts those rows into dictionaries. The actual files contain old and new translations of software strings. The dictionary containing the row data looks like this: o={'TermID':'4', 'English':'System Administration', 'Polish':