finally clause does some housekeeping after a possible exception

How to use finally clause

The finally clause does some housekeeping after a possible exception.


x = None # from w  w w.  j a  v  a  2s  . c  o m
try: 
    x = 1/0 
finally: 
    print 'Cleaning up...' 
    del x 




















Home »
  Python »
    Advanced Features »




Exception Handling
File
Module