Re:Python errors as values: Comparing useful patterns from R...
by sethammons on Thursday November 09, 2023 @11:56AM
(#38207510)
python is where I learned to hate exceptions as control flow - Twisted is twisted. Go was such a breath of fresh air. Now I'm back in python primarily and I am constantly wondering what my functions actually take and actually return. Exceptions are just spooky GOTO and a distance. Our logs are littered with them and have to use Sentry to tell us "oops, you introduced a new error path." Our builds are full of warnings and versioning issues. I've yet to see a decent sized python project that is not a mess.
[ Parent
| on HN ]
Re:Python errors as values: Comparing useful patterns from R...
by goodoldneon on Thursday November 09, 2023 @12:05PM
(#38207643)
> Exceptions are just spooky GOTO and a distance
I couldn't agree more! When you throw exceptions it's unclear where the control flow will go
Re:Python errors as values: Comparing useful patterns from R...
by Karellen on Thursday November 09, 2023 @12:24PM
(#38207938)
I just don't see how multiple levels of
if err:
return nil, err
in the call stack makes things any clearer? Or how having many instances of that snippet scattered everywhere makes the code easier to read?
Re:Python errors as values: Comparing useful patterns from R...
by mmnfrdmcx on Thursday November 09, 2023 @12:40PM
(#38208138)
Agreed. It's also objectively worse because you lose the stack trace in the final exception you will display to your user. Enjoy debugging that when a customer sends you an error.
Re:Python errors as values: Comparing useful patterns from R...
by demi56 on Thursday November 09, 2023 @12:57PM
(#38208365)
Or you could use a 3rd party error package that’s not a good excuse because the standard don’t have it as a priority
Re:Python errors as values: Comparing useful patterns from R...
by goodoldneon on Thursday November 09, 2023 @04:48PM
(#38211828)
It makes the happy path harder to read but the unhappy paths much clearer. I hated this aspect of Go when I first started with the language but I love it now