Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder3.xlned.com!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!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.052 X-Spam-Evidence: '*H*': 0.90; '*S*': 0.00; 'algorithm': 0.04; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'clear.': 0.16; 'dictionary.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'everyone,': 0.19; 'passing': 0.19; 'url:home': 0.24; 'sort': 0.25; 'header:X-Complaints-To:1': 0.27; 'needed.': 0.30; 'code': 0.31; 'url:python': 0.33; 'fri,': 0.33; 'subject:with': 0.35; 'but': 0.35; 'processed': 0.36; 'doing': 0.36; 'next': 0.36; 'entry': 0.36; 'useful': 0.36; 'charset:us-ascii': 0.36; 'url:org': 0.36; 'received:76': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'most': 0.60; 'effectively': 0.66; 'here': 0.66; 'url:htm': 0.73; 'url:items': 0.84; 'lazy': 0.91; 'hand,': 0.93; '2013': 0.98 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Trying to understand working with dicts Date: Sat, 06 Apr 2013 15:20:35 -0400 Organization: > Bestiaria Support Staff < References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-249-24-98.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365276052 news.xs4all.nl 6948 [2001:888:2000:d::a6]:53680 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42936 On Fri, 5 Apr 2013 18:04:03 +0530, inshu chauhan declaimed the following in gmane.comp.python.general: > Hello everyone, > > Here in my part of the code where cc is a dictionary. I want to understand > what actually cc.iterkeys() and cc[k] actually doing. > I am already reading > http://docs.python.org/2/library/stdtypes.html#dict.items > and http://www.tutorialspoint.com/python/python_dictionary.htm but still > not very clear. > > cc = Computesegclass(segimage, refimage) > for k in sorted(cc.iterkeys()): Off hand, .iterkeys() is not doing much useful here. Most all "iterator" systems are designed to generate/fetch the next entry WHEN NEEDED. But you are passing it to a sort routine, and I don't know of any lazy sort algorithm that can return the next /sorted/ item without having processed all the items -- so that is effectively the same as sorted(cc.keys()) -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/