title: Python: Assigning "through" an iterator
body: <p>I have an iterator over a mutable sequence, e.g.</p>
  
  <pre><code>foo = [1, 2, 3, 4, 5]
  for bar in foo:
  </code></pre>
  
  <p>Is there a way to write to the elements in foo by using the reference which is contained in the iterator? The naive assignment:</p>
  
  <pre><code>   bar = 42
  </code></pre>
  
  <p>does not work of course. Is it possible to use the "behind the curtain" reference to the sequence element which is in the iterator ?</p>
  
  <p>PS: The simple solution with using an index </p>
  
  <pre><code>for i in range(len(a)):
     a[i] = 42
  </code></pre>
  
  <p>will not work for my case, as I can't expose the container name. </p>