Python continue from the point where exception was thrown

Posted by James Lin on Stack Overflow See other posts from Stack Overflow or by James Lin
Published on 2012-06-27T03:14:18Z Indexed on 2012/06/27 3:15 UTC
Read the original article Hit count: 207

Filed under:
|
|
|

Hi is there a way to continue from the point where exception was thrown? eg I have the following psudo code

unique code 1
unique code 2
unique code 3

if I want to ignore the exceptions of any of the unique code statements I will have to do it like this:

try:
  #unique code 1
except:
  pass

try:
  #unique code 2
except:
  pass

try:
  #unique code 3
except:
  pass

but this isn't elegant to me, and for the life of me I can't remember how I resolved this kind of problem last time... what I want to have is something like

try:
  unique code 1
  unique code 2
  unique code 3
except:
  continue from last exception raised

© Stack Overflow or respective owner

Related posts about python

Related posts about exception