My .02 on PEP308 + an extra question.

Max M maxm at mxm.dk
Mon Feb 10 14:00:57 EST 2003


Adonis wrote:
> How about something like:

>>>>def iif(cond, ctrue, cfalse):
> 
> ...     if cond: return ctrue
> ...     else: return cfalse

> or am I getting the concept all wrong?


Yes.

What about:

iif(x==y, this_takes_a_second(), this_takes_an_hour(aVal=42))

In your case both the functions will be executed allways. The idea about 
the ternary operator is that only the selected function will be called.

That is why a language construct is nessecary.

-- 

hilsen/regards Max M Rasmussen, Denmark

http://www.futureport.dk/
Fremtiden, videnskab, skeptiscisme og transhumanisme





More information about the Python-list mailing list