title: Iterate through list and handle StopIteration in Python beautifully
body: <p>I am trying to iterate through a list, and I need to perform specific operation when and only when the iteration reached the end of the list, see example below:</p>
  
  <pre><code>data = [1, 2, 3]
  
  data_iter = data.__iter__()
  try:
      while True:
          item = data_iter.next()
          try:
              do_stuff(item)
              break # we just need to do stuff with the first successful item
          except:
              handle_errors(item) # in case of no success, handle and skip to next item
  except StopIteration:
      raise Exception("All items weren't successful")
  </code></pre>
  
  <p>I believe this code isn't too Pythonic, so I am looking for a better way. I think the ideal code should look like this hypothetical piece below:</p>
  
  <pre><code>data = [1, 2, 3]
  
  for item in data:
      try:
          do_stuff(item)
          break # we just need to do stuff with the first successful item
      except:
          handle_errors(item) # in case of no success, handle and skip to next item
  finally:
      raise Exception("All items weren't successful")
  </code></pre>
  
  <p>Any thoughts are welcome.</p>