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

Nick Mellor thebalancepro at gmail.com
Tue Mar 12 01:35:43 EDT 2013


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



More information about the Python-list mailing list