1. Catch something specificif __name__ == "__main__":
So, what does this do if another type of error is thrown? Why is it catching a specific type of error? The rest of the code is logging info - why don't we log the error? How does this make troubleshooting easy, or even possible?
2. Throw something specific
The pattern above is of course fine when the run function works like this:
3. Tell no-one
Make the last line in you script
regardless of whatever just happened. There was a chance the script could return the exit code of whatever it called, so typing the extra line is first, effort, second achieves nothing, and finally means no-one will notice if something went wrong. Or at least not at the time. Perhaps whoever did that thought a shell script won't exit without the keyword exit at the end.
There are others - I'll add them as I find them.
Post a Comment