[Python-Dev] Requesting pronouncement on PEP 463: Exception-catching expressions

Guido van Rossum guido at python.org
Wed Mar 12 18:09:24 CET 2014


On Tue, Mar 11, 2014 at 9:10 PM, Chris Angelico <rosuav at gmail.com> wrote:

> PEP 463, Exception-catching expressions, is stable and I believe ready
> for pronouncement. Drumroll please...
>
> http://www.python.org/dev/peps/pep-0463/
>
> PEP: 463
> Title: Exception-catching expressions
> Version: $Revision$
> Last-Modified: $Date$
> Author: Chris Angelico <rosuav at gmail.com>
> Status: Draft
> Type: Standards Track
> Content-Type: text/x-rst
> Created: 15-Feb-2014
> Python-Version: 3.5
> Post-History: 20-Feb-2014, 16-Feb-2014
>
>
> Abstract
> ========
>
> Just as PEP 308 introduced a means of value-based conditions in an
> expression, this system allows exception-based conditions to be used
> as part of an expression.
>

I want to reject this PEP. I think the proposed syntax is acceptable given
the desired semantics, although it's still a bit jarring. It's probably no
worse than the colon used with lambda (which echoes the colon used in a def
just like the colon here echoes the one in a try/except) and definitely
better than the alternatives listed.

But the thing I can't get behind are the motivation and rationale. I don't
think that e.g. dict.get() would be unnecessary once we have except
expressions, and I disagree with the position that EAFP is better than
LBYL, or "generally recommended" by Python. (Where do you get that? From
the same sources that are so obsessed with DRY they'd rather introduce a
higher-order-function than repeat one line of code? :-)

This is probably the most you can get out of me as far as a pronouncement.
Given that the language summit is coming up I'd be happy to dive deeper in
my reasons for rejecting it there (if there's demand).

I do think that (apart from never explaining those dreadful acronyms :-)
this was a well-written and well-researched PEP, and I think you've done a
great job moderating the discussion, collecting objections, reviewing
alternatives, and everything else that is required to turn a heated debate
into a PEP. Well done Chris (and everyone who helped), and good luck with
your next PEP!

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140312/010c4b73/attachment.html>


More information about the Python-Dev mailing list