News for hackers. Stuff that matters.
Re:Handling exceptions in Python like a pro by stevula on Thursday May 20, 2021 @03:10AM (#27218277)
Exception chaining (`raise from`) was new to me but after reading the docs it seems to be the default behavior in except/finally blocks, so the examples from the article don’t actually add anything. It doesn’t hurt to be explicit though.

https://docs.python.org/3/tutorial/errors.html#exception-cha...

Re:Handling exceptions in Python like a pro by Doxin on Thursday May 20, 2021 @03:20AM (#27218340)
Using "raise foo from bar" changes the message between the exceptions from "During handling of the above exception, another exception occurred:" to "The above exception was the direct cause of the following exception:"

So yes, these days the whole "raise from" construct is nearly pointless. Used to be that exception chaining wasn't automatic though.

Re:Handling exceptions in Python like a pro by aidos on Thursday May 20, 2021 @03:18PM (#27225767)
I believe there’s a subtle difference in the meanings. You can raise or raise from. In either case the chaining means you get to see both messages. But one implies the original error is the cause. It’s so subtle that I don’t recall which is which!