Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #51150
| References | <51EF2AD8.3080105@stoneleaf.us> <ksnrr9$k4t$1@ger.gmane.org> <CAHVvXxQGCFJe7ud+mwh4zhnq5F7xvHJX1pCtGCjMaFtjBwY=iQ@mail.gmail.com> <51EFF957.1040707@stoneleaf.us> |
|---|---|
| Date | 2013-07-25 02:34 +1000 |
| Subject | Re: Python 3: dict & dict.keys() |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5052.1374684136.3114.python-list@python.org> (permalink) |
On Thu, Jul 25, 2013 at 1:57 AM, Ethan Furman <ethan@stoneleaf.us> wrote: > On 07/24/2013 05:51 AM, Oscar Benjamin wrote: >> What do you mean? Why would you want to create a temporary list just to >> iterate over it explicitly or implicitly (set, >> sorted, max,...)? > > You wouldn't. But you don't need .keys() for that either as you can just > use the dict itself. 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. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Python 3: dict & dict.keys() Chris Angelico <rosuav@gmail.com> - 2013-07-25 02:34 +1000
csiph-web