def _mutable_iter(dict):
while dict:<EOL><INDENT>prev_key = next(iter(dict))<EOL>yield prev_key, dict.pop(prev_key)<EOL><DEDENT>
Iterate over items in the dict, yielding the first one, but allowing
it to be mutated during the process.
>>> d = dict(a=1)
>>> it = _mutable_iter(d)
>>> next(it)
('a', 1)
>>> d
{}
>>> d.update(b=2)
>>> list(it)
[('b', 2)]