Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4.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: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'plenty': 0.07; 'builtin': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:keys': 0.09; 'assume': 0.14; 'language.': 0.14; 'dict': 0.16; 'fly.': 0.16; 'iterating': 0.16; 'iterator': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:values': 0.16; 'language': 0.16; 'wrote:': 0.18; 'have:': 0.19; 'header:User- Agent:1': 0.23; 'subject:/': 0.26; 'asking': 0.27; 'values': 0.27; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'database,': 0.30; 'reply.': 0.31; 'could': 0.34; 'but': 0.35; 'there': 0.35; 'method': 0.36; 'thank': 0.38; 'to:addr:python- list': 0.38; 'short': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'entire': 0.61; 'myself': 0.63; 'our': 0.64; 'grab': 0.64; 'interest': 0.64; 'received:2': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: grab dict keys/values without iterating ?! Date: Wed, 11 Dec 2013 16:06:37 +0000 References: <52A7AB8C.8030700@arcor.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-195-123.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: <52A7AB8C.8030700@arcor.de> 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1386777997 news.xs4all.nl 2855 [2001:888:2000:d::a6]:47249 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:61592 On 11/12/2013 00:02, Tamer Higazi wrote: > Hi people! > > Is there a way to get dict by search terms without iterating the entire > dictionary ?! > > Let us assume I have: > > {'Amanda':'Power','Amaly':'Higgens','Joseph':'White','Arlington','Black','Arnold','Schwarzenegger'} > > I want to grab the dict's key and values started with 'Ar'... > > I could make an iterator and look if it's inside. > I wasn't able to find it, but I am asking myself if dict has a builtin > method to get me these key/values on the fly. > > Why do I ask you?! I am working with the ZODB Database, where I make use > of a PersistentDict and PersistentList, and I want > > > I would thank you for a short reply. > > Tamer Plenty of answers already but this may be of interest http://stackoverflow.com/questions/2288901/best-data-structure-for-crossword-puzzle-search?lq=1 -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence