Using finally clauses. : Exception finally « Exception « Python






Using finally clauses.

Using finally clauses.
def raiseExceptionDoNotCatch():
   try:
      print "In raiseExceptionDoNotCatch"
      raise Exception
   finally:
      print "Finally executed in raiseExceptionDoNotCatch"

   print "Will never reach this point"

print "\nCalling raiseExceptionDoNotCatch"

try:
   raiseExceptionDoNotCatch()
except Exception:
   print "Caught exception from raiseExceptionDoNotCatch in main program."

           
       








Related examples in the same category