conditional expressions (RE: Loop-and-a-half (Re: Curious assignment behaviour))

Ian Parker parker at
Mon Oct 15 09:33:03 CEST 2001

In article <7xitdha8tg.fsf at>, Paul Rubin <phr-
n2001d at> writes
>"Tim Peters" < at> writes:
>> > x = if e1 then (e2) else (e3)
>> > and
>> > x = (if e1 then (e2) else (e3))
>> > should be equivalent and they preserve clarity.
>> The latter form would be accepted, but not the former (and the former cannot
>> be accepted, which is a question of parser technology, not of taste).
>How did Algol 60 deal with this?   

to excess, and with a more complicated parser, I imagine:

Because statements are expressions in Algo68, the 'if' clause returns a
value, and can be used as both a statement and an expression, and either
can be squeezed onto one line or spread across multiple lines.

But there are two ways of writing the 'if' clause:

'bold' style:           if v then w elif x then y else z fi     
'brief' style:          ( v > | w |: x | y | z)

In both cases the elif ('|:') can be repeated as many times as you can
face it, and both the elif and else clauses are optional

Doesn't help at all does it?   However, it does suggest the question:
Would this new Python conditional expression support:

Ian Parker

More information about the Python-list mailing list