Skip to content

Instantly share code, notes, and snippets.

@GrahamDumpleton
Created November 7, 2013 03:51
Show Gist options
  • Save GrahamDumpleton/7348692 to your computer and use it in GitHub Desktop.
Save GrahamDumpleton/7348692 to your computer and use it in GitHub Desktop.
Why list(six.iteritems(d)) is bad.
>>> d = { "a": "b" }
>>> i = iter(d.iteritems())
>>> i
<dictionary-itemiterator object at 0x1072d8cb0>
>>> d["c"] = "d"
>>> list(i)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: dictionary changed size during iteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment