On Thu, Jul 25, 2013 at 3:17 AM, Terry Reedy <tjre...@udel.edu> wrote: > On 7/24/2013 12:34 PM, Chris Angelico wrote: > >> 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. > > This is > coupled with the fact that the default meaning of 'item in collection' is > that iterating over 'collection' eventually produces 'item' or a value equal > to 'item'.
Ahh, that makes sense. I never thought of iteration and 'in' being connected like that, but yes, that's a solid reason for doing it that way. ChrisA -- http://mail.python.org/mailman/listinfo/python-list