[Python-Dev] (try-except) conditional expression similar to (if-else) conditional (PEP 308)

Jeff McAninch mcaninch at lanl.gov
Fri Aug 7 12:14:59 CEST 2009

Should be legal, right?, since syntax would be
   <expression> except <expression> if <exception>

Dino Viehland wrote:
> On option 1 is this legal then?
> x = float(string) except float('nan') if some_check() else float('inf') if ValueError
Thinking more about the syntax options: if P.J.'s "if" Option is used, 
it should also be optional.
That is, I would want this to also be legal,
  <expression> except <expression>
to trap any exception when robustness is more important than catching a 
specific exception.

What would be the typical next step in trying to put this forward?  A 
draft PEP?

Jeffrey E. McAninch, PhD
Physicist, X-2-IFD
Los Alamos National Laboratory
Phone: 505-667-0374
Email: mcaninch at lanl.gov

More information about the Python-Dev mailing list