Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29485

Re: A little morning puzzle

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <antoon.pardon@rece.vub.ac.be>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.017
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'skip:[ 20': 0.03; 'received:134': 0.05; 'dct': 0.16; 'dictionaries': 0.16; 'keys.': 0.16; 'wrote:': 0.17; 'keys': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values.': 0.33; 'to:addr:python- list': 0.33; 'list': 0.35; 'item': 0.37; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'where': 0.40; 'pardon': 0.84
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AoYjABW2WVCGuA9G/2dsb2JhbABFiFewN4I7A4QoAQEFeBELGAkWDwkDAgECAUUTCAKHfLFniQeMSYF1gx8DlWSFTYpUgmg
Date Wed, 19 Sep 2012 14:13:17 +0200
From Antoon Pardon <antoon.pardon@rece.vub.ac.be>
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20120726 Iceowl/1.0b1 Icedove/3.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: A little morning puzzle
References <k3c9jb$2gr$1@ger.gmane.org>
In-Reply-To <k3c9jb$2gr$1@ger.gmane.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.912.1348056865.27098.python-list@python.org> (permalink)
Lines 9
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348056865 news.xs4all.nl 6986 [2001:888:2000:d::a6]:59304
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29485

Show key headers only | View raw


On 19-09-12 13:17, 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?
common_items = reduce(opereator.__and__, [set(dct.iteritems()) for dct
in lst])
common_keys = set([item[0] for item in common_items])

-- 
Antoon Pardon

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: A little morning puzzle Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2012-09-19 14:13 +0200

csiph-web