PEP308: Yet another syntax proposal

Bengt Richter bokr at oz.net
Tue Feb 11 06:16:42 CET 2003


On Mon, 10 Feb 2003 10:23:11 -0800 (PST), Dave Brueck <dave at pythonapocrypha.com> wrote:

>On Mon, 10 Feb 2003, Aahz wrote:
>
>> In article <YUP1a.3080$SB2.242 at nwrddc03.gnilink.net>,
>> Raymond Hettinger <python at rcn.com> wrote:
>> >
>> >I suggest:
>> >
>> >    cond  ??  val1  ||  val2
        cond  ->  val1  ->  val2

which is short for
        cond  ->  val1  ><  True ->  val2

which is a two-condition version of
        cond  ->  val1  ><  cond2 -> val2 >< cond3 -> val3 >< True -> valdefault
       

>>
>> +0.5
>>
>> I still have yet to see a clear explanation of why short-circuit is
>> necessary
>
>Short-circuit evaluation is never "necessary" in _any_ language - it's
>just very, very useful sometimes. Python's 'and' operator doesn't _have_
>to be a short-circuit operator, but it's far more useful because it is.
>
>> and therefore iif() unreasonable.
>
>Several of the previous examples have already illustrated this:
>
>z = iif(x, x.getPref(), 'Not specified')
 z = x -> x.getPref() -> 'Not Specified'

>
>is broken without short-circuiting.

Regards,
Bengt Richter




More information about the Python-list mailing list