Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4964
| From | Paul Rubin <no.email@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: dictionary size changed during iteration |
| References | (1 earlier) <mailman.644.1303306435.9059.python-list@python.org> <roy-FE896A.09154622042011@news.panix.com> <7xd3jukyn9.fsf@ruckus.brouhaha.com> <roy-4A30FD.18122007052011@news.panix.com> <4dc6f077$0$41117$e4fe514c@news.xs4all.nl> |
| Date | 2011-05-08 12:42 -0700 |
| Message-ID | <7xhb952d40.fsf@ruckus.brouhaha.com> (permalink) |
| Organization | Nightsong/Fort GNOX |
Hans Mulder <hansmu@xs4all.nl> writes:
> How about:
> changes = filter(is_bad, d)
> Or would that be too compact?
I thought of writing something like that but filter in python 3 creates
an iterator that would have the same issue of walking the dictionary
while the dictionary is mutating.
changes = list(filter(is_bad, d))
should work.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: dictionary size changed during iteration Peter Otten <__peter__@web.de> - 2011-04-20 15:33 +0200
Re: dictionary size changed during iteration Roy Smith <roy@panix.com> - 2011-04-22 09:15 -0400
Re: dictionary size changed during iteration Laszlo Nagy <gandalf@shopzeus.com> - 2011-05-06 18:21 +0200
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