Iterating over a dictionary

Alex Martelli alex at magenta.com
Wed Aug 9 05:34:41 EDT 2000


"Thomas Gagne" <tgagne at ix.netcom.com> wrote in message
news:399039FB.BCFC3A8D at ix.netcom.com...
> Yes, I think it was what I meant.
>
> I was looking for something similar to Smalltalk's aCollection::do:aBlock
> which invoke aBlock on each member of the collection.

But what is 'each member' for a dictionary?  Each (key,value) pair?  Each
key?  Each value?  Python doesn't try to second-guess the programmer's
intentions on that, which I guess is the rationale for not allowing sequence
like access to a mapping (at least, not to a built-in dictionary).
"Explicit
is better than implicit" being a Python mantra...


Alex






More information about the Python-list mailing list