For this specific use-case using try..except..else
is the cleanest solution, the else
clause will be executed if no exception was raised.
NOTE: The else
clause must follow all except
clauses
for i in iterator:
try:
# Do something.
except:
# Handle exception
else:
# Continue doing something