Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #51142 > unrolled thread

Re: Python 3: dict & dict.keys()

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2013-07-24 09:15 -0600
Last post2013-07-24 09:15 -0600
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.


Contents

  Re: Python 3: dict & dict.keys() Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-24 09:15 -0600

#51142 — Re: Python 3: dict & dict.keys()

FromIan Kelly <ian.g.kelly@gmail.com>
Date2013-07-24 09:15 -0600
SubjectRe: Python 3: dict & dict.keys()
Message-ID<mailman.5044.1374678950.3114.python-list@python.org>
On Wed, Jul 24, 2013 at 8:58 AM, Skip Montanaro <skip@pobox.com> 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,...)?
>
> Because while iterating over the keys, he might also want to add or
> delete keys to/from the dict.  You can't do that while iterating over
> them in-place.

None of the (set, sorted, max, ...) cases will add or delete keys
while iterating.  For the occasional for loop where the programmer
does want to do that, you can still explicitly create a temporary list
with list().

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web