A library approach to the ternary operator

Lenard Lindstrom nada at nowhere.xxx
Sat Mar 22 18:22:32 EST 2003


"Lenard Lindstrom" <nada at nowhere.xxx> wrote in message
news:KqLea.42008$Ty5.2786625 at news0.telusplanet.net...
>...
> # ternary module
> def select(test, fn_iftrue, fn_iffalse):
>     if test:
>         return fn_iftrue()
>     return fn_iffalse()
>
> then:
>
> from ternary import *
> x = select(condition, lambda:true_result, lambda:false_result)
>...
I see that PEP 312 mentions this form of a conditional operation as an
example of use.

Lenard Lindstrom
"%s@%s.%s" % ("len-l.", "telus", "net")







More information about the Python-list mailing list