[Python-ideas] except expression

Chris Angelico rosuav at gmail.com
Thu Feb 13 23:23:06 CET 2014


On Fri, Feb 14, 2014 at 9:11 AM, Zachary Ware
<zachary.ware+pyideas at gmail.com> wrote:
> On Thu, Feb 13, 2014 at 4:02 PM, Amber Yust <amber.yust at gmail.com> wrote:
> <cut>
>> On Thu Feb 13 2014 at 2:00:00 PM, Zachary Ware
>> <zachary.ware+pyideas at gmail.com> wrote:
>>> What about just allowing simple try...except constructs to be
>>> condensed to a single line?
>>>
>>>    foo = try bar() except BarException as e e.args[0]
> <paste>
>> The last part of that ("as e e.args[0]") is a pain to read due to no clear
>> separation, just whitespace.
>
> I don't disagree, but it's less bad than some of the other
> alternatives :).  It's also not quite as bad when not using the
> exception (which I suspect would be somewhat more common):
>
>    foo = try bar() except BarException "default"

Looks like a bug magnet, if nothing else. Are you allowed newlines in
that construct?

ChrisA


More information about the Python-ideas mailing list