A library approach to the ternary operator

Brandon Beck bbeck at NOSPAM.austin.rr.com
Fri Mar 21 23:30:30 EST 2003


Jp Calderone wrote:

>>Both of these then work:
>>	x = select(condition, lambda:true_result, lambda:false_result)
>>	x = select(condition, true_result, false_result)
>>
> 
> 
>   ... until you try to use an actual callable as true_result or
> false_result.
> 


Right, I wasn't attempting to imply that it could be used naively 
without understanding at least the general idea of how my implementation 
of select works (i.e. if a callable is passed into it, it will be 
called, and with no arguments).

My real goal was to provide something that can default to a simpler 
syntax if you didn't care about short circuiting behavior, which is 
often the case.  I should have explicitly mentioned the potentially 
misleading case along with my definition.


Brandon





More information about the Python-list mailing list