title: How to catch an exception in the for loop iterator
body: <p>This is a <code>for</code> loop in Python:</p>
  
  <pre><code>for_stmt ::=  "for" target_list "in" expression_list ":" suite
  </code></pre>
  
  <p>Normally, when yielding a value from the <code>expression_list</code> raises an exception, the loop aborts.  Is there an elegant way (short of rewriting the loop using <code>while True</code> or something similar) to catch this exception and continue the loop?</p>
  
  <p>Here is an example:</p>
  
  <pre><code>import csv
  
  csv.field_size_limit(10)
  
  reader = csv.reader(open('test.csv', 'r'))
  for line in reader:
      print(line)
  </code></pre>
  
  <p>with this file:</p>
  
  <pre><code>foo,bar,baz
  xxx,veryverylong,yyy
  abc,def,ghi
  </code></pre>
  
  <p>This aborts at the second line.  I would like a way to skip or log the failing lines and continue.</p>