Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29508
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.beige.octanews.com.POSTED!not-for-mail |
|---|---|
| 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 | Wed, 19 Sep 2012 10:12:59 -0700 |
| Message-ID | <7x627andgk.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:KlK9kpPglq5oBjWmT3JWIBVxYXU= |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Lines | 10 |
| NNTP-Posting-Date | 19 Sep 2012 12:12:59 CDT |
| X-Complaints-To | abuse@octanews.net |
| Xref | csiph.com comp.lang.python:29508 |
Show key headers only | View raw
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