Proposal: function which simulates C ?: operator

Peter Hansen peter at
Mon Jul 12 15:14:09 CEST 2004

Reinhold Birkenfeld wrote:

> Peter Hansen wrote:
>>It won't happen because (a) it's a trivial function to write
> How do you write this function without lambda in the call?

Basically, you use if/then like you are "supposed" to. :-)
But the OP wasn't asking about a short-circuit version, just
the trivial fully evaluated function approach.

>>and (b) there are already several different ways of
>>spelling it with current Python syntax if you don't want a
> One uglier than the other.

Agreed.  Use if/then and save the sanity of your maintenance

>>and (c) I suspect that the requirement for short-circuit
>>evaluation would actually be *more* common in Python than it
>>appears it is in C++ based on your very limited sample population.
> ACK.

Ironic that Bill the Cat changed the meaning of that from
positive to negative. :-)  (Or did he always use mixed-case,
so that all-caps ACK is still uniquely ASCII?)


More information about the Python-list mailing list