title: Add to a deque being iterated in Python?
body: <p>I have a deque in Python that I'm iterating over. Sometimes the deque changes while I'm interating which produces a <code>RuntimeError: deque mutated during iteration</code>.</p>
  
  <p>If this were a Python list instead of a deque, I would just iterate over a copy of the list (via a slice like <code>my_list[:]</code>, but since slice operations can't be used on deques, I wonder what the most pythonic way of handling this is?</p>
  
  <p>My solution is to import the copy module and then iterate over a copy, like <code>for item in copy(my_deque):</code> which is fine, but since I searched high and low for this topic I figured I'd post here to ask?</p>