Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder7.xlned.com!news2.euro.net!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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '"the': 0.07; 'advance': 0.07; 'implements': 0.09; 'keys,': 0.09; 'raises': 0.09; 'cc:addr:python-list': 0.11; '>>': 0.16; 'bracket': 0.16; 'clear.': 0.16; 'command,': 0.16; 'dictionary.': 0.16; 'guessing': 0.16; 'it."': 0.16; 'it."': 0.16; 'iterator': 0.16; 'iterkeys': 0.16; 'notation': 0.16; 'wrote:': 0.18; 'users.': 0.18; 'everyone,': 0.19; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'unix': 0.29; 'andrew': 0.30; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'code': 0.31; 'allows': 0.31; 'class': 0.32; 'url:python': 0.33; 'fri,': 0.33; '"the': 0.34; 'could': 0.34; 'subject:with': 0.35; 'more,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'method': 0.36; 'thanks': 0.36; 'url:org': 0.36; '8bit%:4': 0.38; 'url:library': 0.38; 'pm,': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'here': 0.66; 'nobody': 0.68; 'url:htm': 0.73; 'square': 0.74; 'url:datamodel': 0.84; 'url:html#object': 0.84; 'url:items': 0.84; 'url:reference': 0.84; 'to:none': 0.92; '2013': 0.98 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-received:x-originating-ip:in-reply-to:references :date:message-id:subject:from:cc:content-type:x-gm-message-state; bh=zHGqxvoGY2lZXbULNLWg8kfVKm90fm1mG8od7RCt4Us=; b=c0R3Kw5klVP5udVYIMLfySMwRgDf98I1DBdKo+XTgRMlddlHiKf/yNJOWeDYhQamaY IPD5fW3JMYRQntKIWmOR94YArhRIK0NXBHSYsBiBlaFguCe8n8xzA9jpuyIPROccYWs4 Q/hlDE0su4FL7kmogfri4B/d0/IscycFnF7uCFsTau5OSZ4fZTNIIWt5o94LcjFlHTo7 Ud2+lmOhJiGxHq7ZGcpq3QzapGUm/u7Kfojzywub/F2ihFf8iKOKYwKocT2W0RIShWxT YND4Rr4Kt+S9B7DEyjuF5C0M6Uati9cufrQexw9gWN8LgazzHTPhEyQHepk5V0LJDXIM V8fw== MIME-Version: 1.0 X-Received: by 10.182.144.42 with SMTP id sj10mr8584265obb.66.1365179094331; Fri, 05 Apr 2013 09:24:54 -0700 (PDT) X-Originating-IP: [220.245.216.139] In-Reply-To: References: Date: Sat, 6 Apr 2013 02:24:54 +1000 Subject: Re: Trying to understand working with dicts From: Dylan Evans Cc: "python-list@python.org" Content-Type: multipart/alternative; boundary=14dae9399163f90b2504d99f8640 X-Gm-Message-State: ALoCoQmCY0qpkfjz7S95KMgK8AtSlOpzHeM20VXvMJhA5FmFX9+uPna4lEz4C2wwv8LOsZwRKBz/ 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: 96 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1365179097 news.xs4all.nl 6928 [2001:888:2000:d::a6]:59094 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:42838 --14dae9399163f90b2504d99f8640 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Apr 5, 2013 at 10:34 PM, inshu chauhan wrote: > 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()): > i = argmax(cc[k]) > print >> f, i+1 > > Not sure what Computesegclass is but i am guessing that it is a class which implements __getitem__ and __setitem__, which allows the use of the square bracket notation cc[k], you could also write cc.__getitem__(k) , if you really wanted to. See http://docs.python.org/2/reference/datamodel.html#object.__getitem__ iterkeys returns an iterator over the dictionary keys, which is an object with a next method which returns each key in the dictionary until there are no more, then it raises StopIteration. > Thanks in Advance > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- "The UNIX system has a command, nice ... in order to be nice to the other users. Nobody ever uses it." - Andrew S. Tanenbaum --14dae9399163f90b2504d99f8640 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

= On Fri, Apr 5, 2013 at 10:34 PM, inshu chauhan <insideshoes@gmail.com<= /a>> wrote:

Not sure what Computesegclass is but i am guessing that= it is a class which implements __getitem__ and __setitem__, which allows t= he use of the square bracket notation cc[k], you could also write cc.__geti= tem__(k) , if you really wanted to.=A0

iterkeys returns an iterator over the dictionary keys, which is an object w= ith a next method which returns each key in the dictionary until there are = no more, then it raises StopIteration.
=A0



--
&qu= ot;The UNIX system has a command, nice ... in order to be nice to the other= users. Nobody ever uses it." - Andrew S. Tanenbaum
--14dae9399163f90b2504d99f8640--