Dict to "flat" list of (key,value)

John Machin sjmachin at lexicon.net
Sat Aug 2 20:28:53 EDT 2003


On Sat, 02 Aug 2003 12:41:19 GMT, "Raymond Hettinger"
<vze4rx4y at verizon.net> wrote:


>it-all-starts-with-a-good-data-structure-ly yours,

Amen, brother. 

Even worse: I recall seeing code somewhere that had a data structure
like this:

{k1: [v1,v2], k2: v3, k3: None, ...}
instead of 
{k1: [v1,v2], k2: [v3], k3: [], ...}

I liked the elegant code example for building a book index. However in
practice the user requirement would be not to have duplicated page
numbers when a word occurs more than once on the same page. If you can
achieve that elegantly, please post it!

Cheers,
John






More information about the Python-list mailing list