Created
November 7, 2013 03:51
-
-
Save GrahamDumpleton/7348692 to your computer and use it in GitHub Desktop.
Why list(six.iteritems(d)) is bad.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> 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