[Python-ideas] exception based conditional expression, similar to if-else conditional expression

David Stanek dstanek at dstanek.com
Thu Aug 20 04:28:35 CEST 2009


On Wed, Aug 19, 2009 at 7:07 PM, Jeff McAninch<mcaninch at lanl.gov> wrote:
> I would like to propose an expression, similar to the if-else expression,
> that responds to exceptions.

This is a pretty good idea. I can definitely see where I would use it
in my own code. The only thing I would caution is in your simple
example. I would choose to create a module full of conversion
functions. It violates DRY to have the 'try float otherwise Nan'
statement all over the place.

-- 
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek



More information about the Python-ideas mailing list