Proposal: function which simulates C ?: operator

Peter Hansen peter at engcorp.com
Sun Jul 11 22:08:18 EDT 2004


Adal Chiriliuc wrote:

> I didn't know this was discussed so much in the past. I should have
> searched before.

And if you read all of it, you probably wouldn't be making
the following suggestion, either.  :-)

> I now suggest that this function be added without implying that it's
> the Python equivalent of ?: and with the docs clearly explaining that
> it's not ?: and how it differs. 

It won't happen because (a) it's a trivial function to write
on-demand, and (b) there are already several different ways of
spelling it with current Python syntax if you don't want a
function, 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.

-Peter



More information about the Python-list mailing list