4 ms·
> You have to do everything manually You are aware that error handling is done via exceptions python?
by chronial 8y ago
> You have to do everything manually
You are aware that error handling is done via exceptions python?
- pas 8y agoYou are aware that there's no compiler, and that you have to write the try-except-finally? I'm talking about how weak guarantees Python gives compared to Bash about the correctness of the program. It's easy to get None-s, it's too easy to forget to handle file not found or lack of permission.
- xapata 8y agoMaybe you should start raising exceptions instead of returning None. I've almost never wanted to have my program do anything but crash upon file not found or permission error.
- kemitche 8y agoFor most scripts, handling file not found isn't gonna happen anyway. Often the result is just printing to standard out "hey I couldn't find file X" then bailing. An uncaught exception works well enough for this in many cases, such as build scripts. Same goes for permissions issues and a whole slew of similar scenarios. For many use cases, the lack of forced error checking is a feature. Concrete example: build scripts. As long as the cause of the build failure is clear from the uncaught exception, there's no reason to handle it. I don't need a friendly UI to avoid scaring off non technical users, I just need something that handles the happy path well and crashes with a meaningful stack trace when something unexpected happens.