ternary operator

Paul Rubin phr-n2003b at NOSPAMnightsong.com
Thu Feb 6 02:44:41 CET 2003


"John Roth" <johnroth at ameritech.net> writes:
> > > def cond(selector, valTrue, valFalse):
> > >    if selector:
> > >       return valTrue
> > >    return valFalse
> >
> > Righ, that's easy enough, but how many bugs will be cause by
> > people forgetting that it doesn't short-circuit?
> 
> Which is exactly the reason I suggested that it might be a good idea to
> pursue some way of allowing a function to do lazy evaluation of its
> operands.

value = (lambda: valTrue, lambda: valFalse)[not selector]()




More information about the Python-list mailing list