[Python-Dev] PEP 463: Exception-catching expressions
v+python at g.nevcal.com
Fri Feb 28 03:12:05 CET 2014
On 2/27/2014 3:40 PM, Chris Angelico wrote:
> On Fri, Feb 28, 2014 at 10:33 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On 28 Feb 2014 05:56, "Chris Angelico" <rosuav at gmail.com> wrote:
>>> On Fri, Feb 28, 2014 at 6:36 AM, Glenn Linderman <v+python at g.nevcal.com>
>>>> f() except ((TypeError, AttributeError): "No value")
>>>> is a nice extension to the idea of
>>>> value = expr except (
>>>> Exception1: default1,
>>>> Exception2: default2,
>>>> Exception3: default3,
>>>> Which I've liked since I first saw it, as it neatly solves handling
>>>> except clauses.
>>> You can already list multiple exception types. The definition of the
>>> exception_list is exactly as per the try/except statement (bar the
>>> 'as' keyword, which I would love to see implemented some day).
>> Note that this example is covering the deferred case of multiple except
>> clauses that resolve to different values, not the already handled case of
>> multiple exception types that resolve to the same value.
> The "nice extension" to that notation is already handled, though.
Yes. But the point is really the location of the (), sorry if my "nice
extension" comment is throwing you off that track.
value = expr except (
>> Anyway, even if you choose not to switch the parenthesis requirement in PEP,
>> it should at least make the "colon as in dict display, not as in suite
>> introduction" comparison, and note this as an alternative proposal for the
>> required parentheses.
> Hmm. Not sure that it really helps, but okay. Will word something up.
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: https://mail.python.org/mailman/options/python-dev/v%2Bpython%40g.nevcal.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev