[Python-Dev] PEP 463: Exception-catching expressions

Eli Bendersky eliben at gmail.com
Fri Feb 21 15:49:55 CET 2014

On Fri, Feb 21, 2014 at 6:46 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On 22 February 2014 00:37, Eli Bendersky <eliben at gmail.com> wrote:
> > This goes against anything I understand about how exceptions should and
> > should not be used.
> I think you're thinking of a language that isn't Python - we use
> exceptions for control flow all over the place (it's how hasattr() is
> *defined*, for example).

No, it is Python I'm thinking about. As I mentioned in the reply to Brett's
message, I see a difference between allowing exceptions on expression level
and statement level. The latter is less likely to be abused. Once you add
exceptions into expressions, all bets are off.

For instance, it is sometime non-trivial to know which exceptions some
function may throw. When you write a try...raise statement, you think hard
about covering all the bases. In an expression you're unlikely to, which
opens up a lot of possibilities for bugs. Again, please stop focusing just
on the list[index] case -- the proposal adds a new significant feature to
the language that can (and thus will) be used in a variety of scenarios.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140221/04652562/attachment.html>

More information about the Python-Dev mailing list