manually lower exception in python -


is there way lower exception execute rest of try statement before exception hit , program exits?

while(true):     try:         1         error occurs here         2     except error e:          if(iteration == 2):              iteration += 1              # here want go 2 instead of exit()          exit() 

the try statement:

if present, specifies ‘cleanup’ handler. try clause executed, including except , else clauses. if exception occurs in of clauses , not handled, exception temporarily saved. clause executed. if there saved exception, re-raised @ end of clause. if clause raises exception or executes return or break statement, saved exception discarded:

def f():     try:         1/0     finally:         return 42  >>> f() 42 

Comments