FW: [Python-Dev] conditional expressions?
Paul Prescod
paul at ActiveState.com
Mon Oct 15 21:16:22 EDT 2001
Paul Rubin wrote:
>
> m.faassen at vet.uu.nl (Martijn Faassen) writes:
> > * list comprehensions are signalled by the fairly clear [ and ].
> > Conditional expressions use the already fairly strongly
> > overloaded ( and ). Of course I guess they wouldn't really
> > overload them further, but..
>
> A conditional expression analogy to list comprehensions would be
> x = (a if b else c)
> rather than
> x = if a then b else c
The former actually reads better in English:
unit is meters if metric else feet
versus
unit is, if metric, meters, else feet
Paul Prescod
More information about the Python-list
mailing list