Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29508
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: A little morning puzzle |
| References | <mailman.907.1348053436.27098.python-list@python.org> |
| Date | 2012-09-19 10:12 -0700 |
| Message-ID | <7x627andgk.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
Neal Becker <ndbecker2@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))
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
A little morning puzzle Neal Becker <ndbecker2@gmail.com> - 2012-09-19 07:17 -0400 Re: A little morning puzzle Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2012-09-19 14:34 +0300 Re: A little morning puzzle Paul Rubin <no.email@nospam.invalid> - 2012-09-19 10:12 -0700
csiph-web