fragment 1 iterates over a *copy* of the dictionarys keys, while fragment 2 iterates over the dictionary
On 5/19/06, J. de Hooge
<[EMAIL PROTECTED]> wrote:
LS
Following code fragments seem to behave inconsistently
[START OF CODE]
# --- Fragment 1
#
# Accepted by CPython
#
# Accepted by IronPython1.0 B6
dictionary = dict (zip (range (10), range (0, 100, 10)))
print dictionary
for key in dictionary.keys ():
dictionary [key] = 100 * key
print dictionary
# --- Fragment 2: IronPython objects to the following, CPython thinks its OK
#
# Accepted by CPython
#
# Rejected by IronPython1.0 B6:
# Traceback (most recent call last):
# File C:\activ_dell\prog\qQuick\try\try.py, line 29, in
Initialize
# RuntimeError: dictionary changed size during iteration
dictionary = dict (zip (range (10), range (0, 100, 10)))
print dictionary
for key in dictionary:
dictionary [key] = 100 * key
print dictionary
# --- Shouldn't fragments 1 and 2 be both rejected or both accepted by
IronPython?
[END OF CODE]
Kind regards,
Jacques de Hooge
[EMAIL PROTECTED]
_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
