[Python-3000] Default dict iterator should have been iteritems()
Terry Reedy
tjreedy at udel.edu
Tue Sep 4 21:18:59 CEST 2007
"Noam Raphael" <noamraph at gmail.com> wrote in message
news:b348a0850709040149i6d9d7183ped5d393d492d3824 at mail.gmail.com...
| The reasoning is simple: Iteration over an object usually gets all the
| data it contains. A dict can be seen as an unordered collection of
| tuples (key, value), indexed by key. So, iteration over a dict should
| yield those tuples.
Given that viewpoint, yes. But a dict can also be seen as a set of objects
that happen to have a value attached (like a graph with labelled nodes,
which is still 'made up of' nodes rather than (node,label) pairs). From
this viewpoint, yielding the objects is sensible.
By itself, I think the decision was a toss-up. But consistency with 'in',
which is not a toss-up, tips the balance.
tjr
More information about the Python-3000
mailing list