Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!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.056 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'value,': 0.03; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'shaw': 0.09; 'dictionary,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'storing': 0.16; 'subject:key': 0.16; 'keys': 0.22; 'second': 0.24; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'dan': 0.29; 'dictionary': 0.29; 'knows': 0.32; 'getting': 0.33; 'subject:?': 0.34; 'to:addr :python-list': 0.35; 'but': 0.36; 'there': 0.36; 'subject:: ': 0.37; 'received:org': 0.38; 'self': 0.38; 'method': 0.39; 'to:addr:python.org': 0.39; 'provide': 0.61; 'effective': 0.62; 'interest': 0.64; 'our': 0.64; 'request.': 0.66; '8bit%:40': 0.66; 'skip:\xe2 10': 0.70; 'power': 0.72; '_o__)': 0.84; 'bernard': 0.84; 'received:125': 0.84; 'belief': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ben Finney Subject: Re: Looking up a dictionary _key_ by key? Date: Wed, 24 Jun 2015 10:33:50 +1000 References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Gmane-NNTP-Posting-Host: jigong.madmonks.org X-Public-Key-ID: 0xAC128405 X-Public-Key-Fingerprint: 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-pubkey.asc X-Post-From: Ben Finney User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) Cancel-Lock: sha1:C5dM1GadiW+KwphqPoRoxoKPcLc= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435106041 news.xs4all.nl 2868 [2001:888:2000:d::a6]:53888 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93053 Dan Stromberg writes: > Is there a way of getting the key used by the dictionary, short of > storing a reference to it in the value, or using a second dictionary? The dictionary knows its keys and can provide them on request. Call the ‘dict.keys’ method to get them as a collection. -- \ “Capitalism has destroyed our belief in any effective power but | `\ that of self interest backed by force.” —George Bernard Shaw | _o__) | Ben Finney