Noam Raphael schrieb: > On 9/4/07, Greg Ewing <[EMAIL PROTECTED]> wrote: >> Noam Raphael wrote: >> > The default dict iterator should in principle be iteritems(), and not >> > iterkeys(). >> >> This was discussed at length back when "in" support was >> added to dicts. There were reasons for choosing to do it >> the way it's done, and I don't think it's likely to be >> changed. >> > Just out of curiousity - do you remember these reasons? I just have > the feeling that back then, iterations were less common, since you > couldn't iterate over dicts without creating new lists, and you didn't > have list comprehensions and generators. You couldn't write an > expression such as > dict((x, y) for y, x in d) > to quickly get the inverse permutation, so the relative ugliness of > dict((x, y) for y, x in d.items()) > was not considered.
Well, what about dict((x, d[x]) for x in d) ? Doesn't strike me as ugly... Georg -- Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out. _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com