Created
May 1, 2018 15:35
-
-
Save jbdrvl/e934e4d846667e4602566a0ceab5c7ee to your computer and use it in GitHub Desktop.
Test of the {<try>, <finally>} keywords.
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
| #!/usr/bin/env python3 | |
| ''' | |
| Will loop infinitely until stopped by the user (ctrl+C). | |
| When interrupted, the program will print "Leaving main!" before raising the <KeyboardInterrupt> exception. | |
| Not very useful but I thought it was pretty cool. | |
| ''' | |
| def main(): | |
| try: | |
| while True: | |
| pass | |
| finally: | |
| print("Leaving main!") | |
| if __name__=="__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment