[Python-ideas] Block-Scoped Exception Handlers
Michael Selik
michael.selik at gmail.com
Fri May 6 15:38:01 EDT 2016
On Fri, May 6, 2016 at 1:56 PM Kyle Lahnakoski <klahnakoski at mozilla.com>
wrote:
> On 5/6/2016 1:28 PM, Michael Selik wrote:
>
> This avoids the excessive indentation and helps improve the reading of how
> an error in the group will break but an error in one will continue. Does
> that not satisfy?
>
> Yes, extracting deeply nested code into methods will reduce the
> indentation. It is disappointing that I must come up with a name for a
> method that has only one call site. More disappointment for each local
> variable I must pass to that method,. More disappointment for each
> variable the code bock update this locals.
>
It is difficult to come up with a good name sometimes, but I feel that
effort often gives me a better understanding of my code. I don't mind that
there's only one call site. In fact, many of the functions I write only
have one call site. I often break code out to a function so that I can give
it a name and make the code easier to read.
I share your distaste for passing the same set of arguments to a function,
it's helper, that helper's helper, and so on down the chain. When it gets
frustrating, that's more incentive to refactor. Sometimes it pushes me to
realize a better design. It's often a sign of too much interdependence,
which is hard to reason about.
Regarding your proposal, even if it were a pleasant syntax, I think the
alternatives are good enough that having both would go against the Zen of
one obvious way.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160506/c1defecc/attachment.html>
More information about the Python-ideas
mailing list