[Python-ideas] except expression

Amber Yust amber.yust at gmail.com
Thu Feb 13 22:26:42 CET 2014


As has been noted earlier in the thread when someone proposed except...if -
there are parsing issues due to if..else already being a ternary expression.

On Thu Feb 13 2014 at 1:18:40 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:

> Chris Angelico wrote:
>
> > phone = addressbook[name] except KeyError or "Unknown"
>
> How about
>
>     phone = addressbook[name] except "Unknown" if KeyError
>
> Yes, it puts things in a different order from the except
> statement, but I don't think that's any worse than the
> if-expression being ordered differently from the if-statement,
> and it has the same benefit, i.e. reading more smoothly.
>
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140213/c799bbac/attachment.html>


More information about the Python-ideas mailing list