if in expression
Fredrik Lundh
fredrik at pythonware.com
Mon Aug 18 04:47:45 EDT 2008
Hrvoje Niksic wrote:
>> If you want lazy evaluation, you can use lambdas:
>>
>> iif(cond, lambda: then, lambda: else_)()
>
> Your code uses "iif" and attempts to evaluate a tuple; could you post
> an example that works?
>
> I ask because it's not clear what you mean by lazy evaluation in this
> context. The ternary "if" expression introduced in Python 2.5 only
> evaluates then_value or else_value depending on the outcome of cond.
> How is that different than using a lambda?
the second part of Diez' answer is a reply to the second part of the
OP's question.
</F>
More information about the Python-list
mailing list