Hello,
      It seems that I can mutate a deque while iterating over it if I
assign to an index, but not if I append to it. Is this the intended
behaviour? It seems a bit inconsistent. Cheers.

Duncan

>>> from collections import deque
>>> d = deque(range(8))
>>> it = iter(d)
>>> next(it)
0
>>> d[1] = 78
>>> next(it)
78
>>> d.append(8)
>>> next(it)
Traceback (most recent call last):
  File "<pyshell#650>", line 1, in <module>
    next(it)
RuntimeError: deque mutated during iteration
>>>
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to