Created
November 19, 2013 04:24
-
-
Save IQAndreas/7540305 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
| try: | |
| state = "initializing" | |
| read_configs() | |
| state = "downloading" | |
| files = get_files() | |
| state = "importing" | |
| import_files(files) | |
| state = "complete" | |
| exception: | |
| if (state == "importing"): | |
| print("WARNING: The script quit before it finished importing. You may have incomplete files stored on the server") | |
| else: | |
| print("Script quit unexpectedly. Please notify the developer"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've never seen
sys.excepthookused. Generally I'll stick all the code in a top-level function, then wrap the call to that function intry/except:And sometimes I'll have something like:
So that I don't need to have an entire function indented inside a
tryblock.