Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42838 > unrolled thread

Re: Trying to understand working with dicts

Started byDylan Evans <dylan@dje.me>
First post2013-04-06 02:24 +1000
Last post2013-04-06 02:24 +1000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Trying to understand working with dicts Dylan Evans <dylan@dje.me> - 2013-04-06 02:24 +1000

#42838 — Re: Trying to understand working with dicts

FromDylan Evans <dylan@dje.me>
Date2013-04-06 02:24 +1000
SubjectRe: Trying to understand working with dicts
Message-ID<mailman.149.1365179097.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

On Fri, Apr 5, 2013 at 10:34 PM, inshu chauhan <insideshoes@gmail.com>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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web