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


Groups > comp.lang.python > #41108

del not working for (exhausted) dict iterable value (Python 3.3)

Newsgroups comp.lang.python
Date 2013-03-11 22:35 -0700
Message-ID <2879f537-1666-46f7-abbf-38204d8184c2@googlegroups.com> (permalink)
Subject del not working for (exhausted) dict iterable value (Python 3.3)
From Nick Mellor <thebalancepro@gmail.com>

Show all headers | View raw


Hi all,

event['Items'] is an exhausted (all used up) iterable.

Now I do the following (lines 142-4):

            event.update({'Attributes': filtered_attributes})
            del event['Items']
            yield event

and get a KeyError on the del statement. 'Items' is a key in the event dictionary at this point.

The full file is here:

https://gist.github.com/nickmellor/5140516

I can get round it by copying all but the 'Items' member to a new dictionary, but obviously I don't want to.

Is there some deep design in Python here, that it won't delete a dict value that's an (exhausted) iterator, or have I found a bug?

Thanks for any help,

Nick

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


Thread

del not working for (exhausted) dict iterable value (Python 3.3) Nick Mellor <thebalancepro@gmail.com> - 2013-03-11 22:35 -0700
  Re: del not working for (exhausted) dict iterable value (Python 3.3) alex23 <wuwei23@gmail.com> - 2013-03-11 22:52 -0700
    Re: del not working for (exhausted) dict iterable value (Python 3.3) Nick Mellor <thebalancepro@gmail.com> - 2013-03-12 15:40 -0700
    Re: del not working for (exhausted) dict iterable value (Python 3.3) Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-03-13 05:02 +0100

csiph-web