They don't do the same thing..<br>fragment 1 iterates over a *copy* of the dictionarys keys, while fragment 2 iterates over the dictionary<br><br><div><span class="gmail_quote">On 5/19/06, <b class="gmail_sendername">J. de Hooge
</b> <<a href="mailto:info@geatec.com">info@geatec.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">LS<br><br>Following code fragments seem to behave inconsistently
<br><br>[START OF CODE]<br><br># --- Fragment 1<br>#<br># Accepted by CPython<br>#<br># Accepted by IronPython1.0 B6<br><br>dictionary = dict (zip (range (10), range (0, 100, 10)))<br><br>print dictionary<br><br>
for key in dictionary.keys ():<br> dictionary [key] = 100 * key<br><br>print dictionary<br><br># --- Fragment 2: IronPython objects to the following, CPython thinks its OK<br>#<br># Accepted by CPython<br>#<br>
# Rejected by IronPython1.0 B6:<br># Traceback (most recent call last):<br># File C:\activ_dell\prog\qQuick\try\try.py, line 29, in<br>Initialize<br># RuntimeError: dictionary changed size during iteration
<br><br>dictionary = dict (zip (range (10), range (0, 100, 10)))<br><br>print dictionary<br><br>for key in dictionary:<br> dictionary [key] = 100 * key<br><br>print dictionary<br><br># --- Shouldn't fragments 1 and 2 be both rejected or both accepted by
<br>IronPython?<br><br>[END OF CODE]<br><br><br>Kind regards,<br>Jacques de Hooge<br><a href="mailto:info@geatec.com">info@geatec.com</a><br><br><br>_______________________________________________<br>users mailing list<br>
<a href="mailto:users@lists.ironpython.com">users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br></blockquote>
</div><br>