Am 24.07.2013 18:34, schrieb Chris Angelico: > Side point: Why is iterating over a dict equivalent to .keys() rather > than .items()? It feels odd that, with both options viable, the > implicit version iterates over half the dict instead of all of it. > Obviously it can't be changed now, even if .items() were the better > choice, but I'm curious as to the reason for the decision.
Consider this: if key in dict: ... for key in dict: ... It would be rather surprising if "in" as containment checks operates on keys and "in" as iterator returns (key, value) tuples. Christian -- http://mail.python.org/mailman/listinfo/python-list