[Python-ideas] except expression

MRAB python at mrabarnett.plus.com
Thu Feb 20 16:24:12 CET 2014


On 2014-02-20 14:46, Rob Cliffe wrote:
>
> On 20/02/2014 13:45, M.-A. Lemburg wrote:
>> On 20.02.2014 02:18, Chris Angelico wrote:
>>> On Thu, Feb 20, 2014 at 11:15 AM, Ethan Furman <ethan at stoneleaf.us> wrote:
>>>> result = 1/x except ZeroDivisionError -> NaN
>>>>
>>>> For the record, I could just as easily live with the colon instead of the
>>>> arrow.
>>>>
>>> Time to open up this branch of the discussion... colon or arrow?
>>>
>>> For the purposes of this debate, I'm comparing these two notations,
>>> and nothing else:
>>>
>>> result = 1/x except ZeroDivisionError -> NaN
>>> result = 1/x except ZeroDivisionError: NaN
>> I'm -1 on both of them.
> I'm afraid answering your post will mean repeating stuff said earlier in
> this thread, but here goes:
>> The colon should stay reserved for starting new blocks of statements.
> It isn't reserved for that - it is already used for slices, dictionary
> literals and lambdas.

It should be said that slices and dict literals do "enclose" the colon,
the first with in[...] and the second within {...}.

@Marc-Andre: Would it be better if the expression containing the except
clause were enclosed in (...), e.g. "result = (1/x except
ZeroDivisionError: NaN)" rather than "result = 1/x except
ZeroDivisionError: NaN"?

[snip]



More information about the Python-ideas mailing list