Dict comp help

Joseph L. Casale jcasale at activenetwerx.com
Thu Jan 24 17:21:44 EST 2013


> >>> data = [{'a': 'xx', 'b': 'yy', 'c': 'zz'},  {'a': 'dd', 'b': 'ee', 'c': 'ff'}] 
> >>> {d["a"]: d["c"] for d in data}
> {'xx': 'zz', 'dd': 'ff'}


Priceless,
That is exactly what I needed, for which I certainly over complicated!


Thanks everyone!
jlc


More information about the Python-list mailing list