jaraco/itertools.py
def _mutable_iter(dict):
	"""
	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)]
	"""
	while dict:
		prev_key = next(iter(dict))
		yield prev_key, dict.pop(prev_key)
def _mutable_iter(dict):
	"""
	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)]
	"""
	while dict:
		prev_key = next(iter(dict))
		yield prev_key, dict.pop(prev_key)
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)]