[Python-Dev] PEP 463: Exception-catching expressions
Glenn Linderman
v+python at g.nevcal.com
Sat Feb 22 03:08:22 CET 2014
On 2/21/2014 5:06 PM, Jan Kaliszewski wrote:
> Or even (still being my favorite):
>
> msg = seq[i] except (IndexError: "nothing")
This syntax actually has a benefit: the parenthesized syntax after
except could become a list, to allow handling different exceptions from
the tried expression with different results:
msg = seq[dictionary[i]] except (IndexError: "nothing", KeyError:
"serious problems")
And still allows nesting:
msg = seq[i] except (IndexError: dictionary[i] except (KeyError: "no
fallback data for %s" % i))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140221/5c2f532b/attachment.html>
More information about the Python-Dev
mailing list