# exception # nested try block # scope of try block: dynamic # exception propagates towards the try block # def g() : print("five") print(10/0) print("six") def f() : print("four") g() print("seven") try : print("one") f() print("ten") print("end of try") except NameError as e : print("no such name") print(e) except Exception as e : print(e, type(e)) # can get the stack trace except : # catch all handler; should be the last print("something wrong") finally: # always executed print("this is final") print("end of program")