Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!feeds.news.ox.ac.uk!news.ox.ac.uk!nntp-feed.chiark.greenend.org.uk!ewrotcd!news.nosignal.org!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'value,': 0.03; 'output': 0.04; 'subject:skip:c 10': 0.07; 'subject:help': 0.07; 'dict': 0.09; 'tackle': 0.09; 'comp': 0.16; 'pointer': 0.17; 'to:name :python-list@python.org': 0.20; 'of.': 0.22; 'thanks!': 0.26; 'received:24': 0.27; 'received:10.0.0': 0.28; 'source': 0.29; 'certain': 0.33; 'extract': 0.33; 'received:10.0': 0.33; 'anyone': 0.33; 'to:addr:python-list': 0.33; 'list': 0.35; 'list.': 0.35; 'but': 0.36; 'charset:us-ascii': 0.36; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'easily': 0.39; 'where': 0.40; 'containing': 0.61; 'received:unknown': 0.63; 'within': 0.64; 'hoping': 0.72; 'premise': 0.84 X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=aTVRNjW1y6NjoOpVf0TT9V0PHXDfZZQvid8DyjJaX1w= c=1 sm=1 a=QxjuIguZGUkA:10 a=7PYXob_7ZXMA:10 a=BLceEmwcHowA:10 a=kj9zAlcOel0A:10 a=oNw28mxuUhXRB3mVwYQ4Ag==:17 a=fwAMeKCokvJI5gTI1Q4A:9 a=CjuIK1q_8ugA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 From: "Joseph L. Casale" To: "python-list@python.org" Subject: Dict comprehension help Thread-Topic: Dict comprehension help Thread-Index: Ac3TXWVNP4x4OdPOStSEWGN69T+4Jg== Date: Thu, 6 Dec 2012 03:03:13 +0000 Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.0.0.200] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 21 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354763128 news.xs4all.nl 6840 [2001:888:2000:d::a6]:37645 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34354 I get a list of dicts as output from a source I need to then extract variou= s dicts=0A= out of. I can easily extract the dict of choice based on it containing a ke= y with=0A= a certain value using list comp but I was hoping to use dict comp so the ou= tput=0A= was not contained within a list.=0A= =0A= reduce(lambda x,y: dict(x.items() + y.items()), filter(lambda z: z['key'] = =3D=3D value, my_list))=0A= =0A= where my_list is a list of dicts. The premise is all dicts in the list have= a unique=0A= value for z['key'].=0A= =0A= Anyone have a pointer as to how I might tackle this without lambdas and onl= y=0A= using dict comp?=0A= =0A= Thanks!=0A= jlc=