A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-August/091080.html below:

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

[Python-Dev] (try-except) conditional expression similar to (if-else) conditional (PEP 308) [Python-Dev] (try-except) conditional expression similar to (if-else) conditional (PEP 308)MRAB python at mrabarnett.plus.com
Fri Aug 7 13:03:16 CEST 2009
Jeff McAninch wrote:
> 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.

Catch all exceptions:

     <expression> except <expression>

Catch specific exceptions, optionally catching all others:

     <expression> except (<expression> if <exception>)+ [else <expression>]

Of course, a catch-all is a bare except, with all its dangers!

> 
> What would be the typical next step in trying to put this forward?  A 
> draft PEP?
> 
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4