Dict comp help

Dave Angel d at davea.name
Thu Jan 24 22:08:43 CET 2013


On 01/24/2013 03:58 PM, Joseph L. Casale wrote:
> Hi,
> Slightly different take on an old problem, I have a list of dicts, I need to build one dict
> from this based on two values from each dict in the list. Each of the dicts in the list have
> similar key names, but values of course differ.
>
>
> [{'a': 'xx', 'b': 'yy', 'c': 'zz'},  {'a': 'dd', 'b': 'ee', 'c': 'ff'}]
>
>
> { 'xx': 'zz', 'dd': 'ff'}
>
>
> Anyone have insight on how to pull this off?
>

Not till you tell us what the pattern is supposed to be.  I can see how 
you might want xx:dd, yy:ee, zz:ff    but have no idea what the intended 
connection is between the source dicts and the result.



-- 
DaveA



More information about the Python-list mailing list