Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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: UNSURE 0.204 X-Spam-Level: ** X-Spam-Evidence: '*H*': 0.61; '*S*': 0.02; 'value.': 0.15; 'subject:compare': 0.16; 'header:User-Agent:1': 0.26; '(e.g.': 0.27; 'subject:list': 0.28; 'dictionary': 0.29; 'to:addr:python- list': 0.33; 'hi,': 0.33; 'list': 0.35; 'functional': 0.36; 'possible': 0.37; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'from:no real name:2**0': 0.60; "'3'": 0.84; 'received:72.249': 0.84 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=MG1Tk2pYz4guXpDfpomfjvrfiJCGjeqeBMy+w0KRwnLpujFzUczSOFmnrfs9KuSkdTmVWadI1eRvF1IHMXL4ZyBxSZzO9TlGSXywEeY46J4aA9b1/lWGAJNSbaGbpntgXwFWQEvp6imMdN9NrIL5zVqwkXcVr2EOmO7vQWSZJBQ=; h=Message-ID:Date:Subject:From:To:User-Agent:MIME-Version:Content-Type:Content-Transfer-Encoding; Date: Thu, 20 Sep 2012 18:58:21 -0400 (EDT) Subject: Functional way to compare things inside a list From: thorsopia@lavabit.com To: python-list@python.org User-Agent: SquirrelMail/1.4.13 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Fri, 21 Sep 2012 09:46:44 +0200 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1348213606 news.xs4all.nl 6964 [2001:888:2000:d::a6]:41208 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:29604 Hi, list = [{'1': []}, {'2': []}, {'3': ['4', '5']}] I want to check for a value (e.g. '4'), and get the key of the dictionary that contains that value. (Yep, this is bizarre.) some_magic(list, '4') => '3' What's the functional way to do it? Is it possible to do it with a one-liner?