I am am looking to restart an iteration if i receive an exception. (... it is reading data from a server, and occasionally gets intermittent error codes, that do not repeat on a retrying).
with open(input, 'rb') as f:
r = unicodecsv.reader(f)
for row in r:
code to request some data from server
if response_code == 200:
code to process response
else:
want to restart the iteration for the current row
If i was using a while loop, this sort of thing would obviously be obvious (e.g. don't increment the number), but given I am iterating over row in a for loop, can't think of a way of forcing a re-do of the current iteration.
Although there are lots of similar sounding titled posts (e.g. how to restart "for" loop in python ? , Python - Way to restart a for loop, similar to "continue" for while loops? , python: restarting a loop ) each of the ones I have found/read seems to get at something different (e.g. just how to restart when get to the end, rather than restarting an iteration should a certain condition occur).
[Python 2.7]