On 18 Aug., 10:22, John Machin <[EMAIL PROTECTED]> wrote:
> On Aug 18, 5:46 pm, [EMAIL PROTECTED] wrote:
> > I'm using IronPython to evaluate expressions, so I can't use the
> > return statement but have to say it in an one-liner.
>
> By "evaluate expressions", do you mean using the eval built-in
>
Fredrik Lundh <[EMAIL PROTECTED]> writes:
> 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 n
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 ter
Hrvoje Niksic schrieb:
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
Since python 2.5, it is
if else
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?
"Diez B. Roggisch" <[EMAIL PROTECTED]> writes:
> Since python 2.5, it is
>
> if else
>
> 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
John Machin wrote:
There is an even more unreadable hack (due to Tim Peters IIRC) that
avoides the false-then problem:
(cond and [then_value] or [else_value])[0]
The correct attribution is "due to Tim Peters (who wishes it was Steve
Majewski)."
--
http://mail.python.org/mailman/listinfo/
On Aug 18, 5:46 pm, [EMAIL PROTECTED] wrote:
> Hi,
> I'm using IronPython to evaluate expressions, so I can't use the
> return statement but have to say it in an one-liner.
By "evaluate expressions", do you mean using the eval built-in
function? If so, find the recent thread addressing this topic;
[EMAIL PROTECTED] schrieb:
Hi,
I'm using IronPython to evaluate expressions, so I can't use the
return statement but have to say it in an one-liner. Using C/C++ I
could use "cond ? then : else" to have an expression-if, but in Python
there's no such operator. The "cond and then or else"-trick onl