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


Groups > comp.lang.python > #4920

Re: dictionary size changed during iteration

Path csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.glorb.com!news-out.octanews.net!indigo.octanews.net!auth.beige.octanews.com.POSTED!not-for-mail
From Paul Rubin <no.email@nospam.invalid>
Newsgroups comp.lang.python
Subject Re: dictionary size changed during iteration
References <4DAED72B.2030400@shopzeus.com> <mailman.644.1303306435.9059.python-list@python.org> <roy-FE896A.09154622042011@news.panix.com>
Date Sat, 07 May 2011 14:07:38 -0700
Message-ID <7xd3jukyn9.fsf@ruckus.brouhaha.com> (permalink)
Organization Nightsong/Fort GNOX
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:83DS3yUX+DYDl1ZYS4A/BoNduLI=
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Lines 9
NNTP-Posting-Date 07 May 2011 16:07:38 CDT
X-Complaints-To abuse@octanews.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4920

Show key headers only | View raw


Roy Smith <roy@panix.com> writes:
> changes = [ ]
> for key in d.iterkeys():
>   if is_bad(key):
>     changes.append(key)

    changes = list(k for k in d if is_bad(k))

is a little bit more direct.

Back to comp.lang.python | Previous | NextNext in thread | Find similar


Thread

Re: dictionary size changed during iteration Paul Rubin <no.email@nospam.invalid> - 2011-05-07 14:07 -0700
  Re: dictionary size changed during iteration Roy Smith <roy@panix.com> - 2011-05-07 18:12 -0400
    Re: dictionary size changed during iteration Hans Mulder <hansmu@xs4all.nl> - 2011-05-08 21:32 +0200
      Re: dictionary size changed during iteration Paul Rubin <no.email@nospam.invalid> - 2011-05-08 12:42 -0700

csiph-web