Created
December 14, 2015 11:51
-
-
Save lanfon72/d970c7416f315b9252e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def try_else(x, y): | |
| a = lambda x, y: x % y | |
| b = lambda x, y: x / y | |
| try: | |
| result = a(x,y) + b(x,y) | |
| f = open('Cookie', 'w+') | |
| except ZeroDivisionError as z: | |
| print(z) | |
| # divide by zero. | |
| except PermissionError as p: | |
| print(p) | |
| # can't open the file. | |
| except Exception as e: | |
| print(e) | |
| # other exceptions. | |
| else: | |
| # all try condition no exception. | |
| # means you have to close filestream. | |
| f.close() | |
| finally: | |
| # clear all content or other things. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment