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

Jae Kwon jkwon.work at gmail.com
Fri Aug 7 02:28:23 CEST 2009


On Aug 6, 2009, at 5:15 PM, Jan Kaliszewski wrote:

>> Syntax Ideas:
>>    Option 1:
>>        x = float(string) except float('nan') if ValueError
>>        op(float(string) except float('nan') if ValueError)
>
> -0.5
> I wouldn't mix up 'if' word with 'except' -- there are different  
> concepts.
>
>>    Option 2:
>>        x = float(string) except ValueError: float('nan')
>>        op(float(string) except ValueError: float('nan'))
>
> +0.5
> IMHO seems to be the best of the propositions. I'd add to it optional
> as (like in present 'try:... except Exc as exc:...')
>

+0.5

the colon implies EOL. how about 'then'?

x = float(string) except ValueError [, e] then float('nan')
[, e] optional

  - Jae

>>    Option 3:
>>        x = float(string) except ValueError else float('nan')
>>        op(float(string) except ValueError else float('nan'))
>
> -1
> IMHO it's illogical. 'else' has completely opposite role in present
> 'try...except...' clauses. It'd be terribly missleading, not only
> for newbies.
>
>
> Cheers,
> *j
>
> -- 
> Jan Kaliszewski (zuo) <zuo at chopin.edu.pl>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas




More information about the Python-ideas mailing list