A little morning puzzle

Paul Rubin no.email at nospam.invalid
Wed Sep 19 13:12:59 EDT 2012


Neal Becker <ndbecker2 at gmail.com> writes:
> I have a list of dictionaries.  They all have the same keys.  I want to find the 
> set of keys where all the dictionaries have the same values.  Suggestions?

Untested, and uses a few more comparisons than necessary:

# ds = [dict1, dict2 ... ]

d0 = ds[0]
ks = set(k for k in d0 if all(d[k]==d0[k] for d in ds))



More information about the Python-list mailing list