[Python-ideas] Block-Scoped Exception Handlers

Kyle Lahnakoski klahnakoski at mozilla.com
Wed May 4 19:15:39 EDT 2016

On 5/4/2016 7:05 PM, cs at zip.com.au wrote:
> I also like context from close to where the exception occurred, while
> doing that catching at whatever the suitable outer layer may be, as
> normal. Let me show you what I do...
> I have a module "cs.logutils":

I really like the idea of using a `with` clause for simplify exception
chaining.  I am concerned I would be missing some of the locals
available at exception time, which the `with` clause would not have
access to, but more introspection may solve that too.  It does not solve
the indent problem, but I could live with that if it made the code
simpler in other ways.

Many of my exception handlers are multiline, and I do not think the
`with` clause strategy would work there.

More information about the Python-ideas mailing list