[Python-ideas] Fwd: Null coalescing operator

Guido van Rossum guido at python.org
Mon Sep 12 23:43:32 EDT 2016


On Mon, Sep 12, 2016 at 5:45 PM, Rob Cliffe <rob.cliffe at btinternet.com> wrote:
>
>
> On 12/09/2016 16:37, Guido van Rossum wrote:
>>
>> For the record, I still really don't like PEP 463. We should strive to
>> catch fewer exceptions, not make it easier to catch them.
>
> Can you please clarify what you are saying in the last sentence?
> The first time I read it, my brain parsed it as "People should raise fewer
> exceptions, i.e. use LBYL less".

(If that means "Leap Before You Look", yes. :-)

> Later it seemed more likely that you meant "The set of exceptions we catch
> in a specific piece of code should not be too large; we should only catch
> those exceptions that we really mean to handle".
> But perhaps you mean something else altogether?
>
> Also I don't see the connection between the first sentence and the second.
> Exception-catching expressions as per PEP 463 just give you a more concise
> way of of doing something you can do with try+except.  Do you mean it would
> make it easier to catch exceptions because you have to type fewer
> characters, and that this would be a bad thing?

Yeah, that's exactly my point. PEP 463 gives you a shorter way to
catch an exception, so it gives you less motivation to find a way to
write your code (or define your API) that doesn't involve catching
exceptions. But APIs involving exceptions are often inferior to APIs
that don't require exception catching. (Yes, I am aware of __next__()
raising StopIteration -- but that API design usually doesn't require
you to catch it.)

-- 
--Guido van Rossum (python.org/~guido)


More information about the Python-ideas mailing list