Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #29480 > unrolled thread
| Started by | Peter Otten <__peter__@web.de> |
|---|---|
| First post | 2012-09-19 13:33 +0200 |
| Last post | 2012-09-19 13:33 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: A little morning puzzle Peter Otten <__peter__@web.de> - 2012-09-19 13:33 +0200
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2012-09-19 13:33 +0200 |
| Subject | Re: A little morning puzzle |
| Message-ID | <mailman.908.1348054351.27098.python-list@python.org> |
Neal Becker wrote:
> 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?
>>> items = [
... {1:2, 2:2},
... {1:1, 2:2},
... ]
>>> first = items[0].items()
>>> [key for key, value in first if all(item[key] == value for item in
items)]
[2]
Back to top | Article view | comp.lang.python
csiph-web