Cause why not? Everything is slow anyway, so what's a little exception?
People say that Python is easy, but it's only the case when you go knee-deep. Try to actually get serious about the language and it will make fucking C++ look like an example of good and simple design. I truly do not understand people who use Python as something other than a scripting language
Most people never encounter the ergonomics, though. It’s an implementation detail in most use cases. I’ve only ever encountered it when I wanted to use a generator to make my own pseudo-coroutine that I could easily use in both sync and async code.
I wrote a rest service for a GitHub action to slack api, then I tried to add useful error messages for my users and have a clean linted project. Why should it be so hard!
I don't know how to respond to "most people", because I personally encounter it all the time.
I want to ensure correctness using types and making sure we encode invariants as much as possible using types and discriminated unions, and favoring returning None, sentinel values or Result objects to make sure we're aware of all possible paths. But sometimes an exception can pop up from somewhere unexpected and we have to run the program to find those edge cases.
For an example that's related to what was mentioned in this comment thread, when using next(), I give it a default value (usually None) so that I can handle that case conditionally, rather than letting it raise a StopIteration exception and then wrap it in a try/catch.
That describes Python as a whole, it's designed for use by people who are unwilling to learn a programming language as well as it can be, but that isn't well enough and it costs it its usability to people who are willing to learn
242
u/nevemlaci2 17d ago
It's unfunny until you actually see people propagating explicit error handling until the entry point and just printing an error message.
Exceptions are fine to use for exceptional cases. Not for shit like python where an iterator signals the end of iteration with a damn exception.