[Python-ideas] Block-Scoped Exception Handlers

Paul Moore p.f.moore at gmail.com
Thu May 5 12:04:29 EDT 2016


On 5 May 2016 at 16:35, Kyle Lahnakoski <klahnakoski at mozilla.com> wrote:
> `raise from` does not solve the excessive indentation problem:  I have many
> `try` clauses, causing deep indentation in my code.  The block-scoped
> exception handlers would mitigate this deep indentation, and make exception
> handling even easier to add.

contextmanager/ExitStack would likely help with the indentation
problem. As would simply breaking out some of the deeply nested code
into independent functions.

It may be that there's a problem worth addressing here, but I suggest
that you wait until you've had a chance to see if the existing
features in Python 3.5 resolve your issues before taking this
suggestion any further.

Paul


More information about the Python-ideas mailing list