Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51156 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2013-07-25 03:58 +1000 |
| Last post | 2013-07-25 03:58 +1000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 03:58 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-07-25 03:58 +1000 |
| Subject | Re: Python 3: dict & dict.keys() |
| Message-ID | <mailman.5057.1374688738.3114.python-list@python.org> |
On Thu, Jul 25, 2013 at 3:17 AM, Terry Reedy <tjreedy@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
Back to top | Article view | comp.lang.python
csiph-web