""" lectureNote/chapters/chapt05/codes/try_finally.py try-finally example, originally from https://docs.python.org/3/tutorial/errors.html """ def divide(x, y): try: result = x / y print("Result is", result) except ZeroDivisionError: print("Division by zero!") finally: print("Executing finally clause, Thanks for testing me!") if __name__ == '__main__': print("calling as divide(1.0,2.0)") divide(1.0,2.0) print("calling as divide(1.0,0.0)") divide(1.0,0.0)