johnroth at ameritech.net
Thu Feb 6 22:05:19 CET 2003
"Paul Rubin" <phr-n2003b at NOSPAMnightsong.com> wrote in message
news:7xlm0udvxy.fsf at ruckus.brouhaha.com...
> "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
> > pursue some way of allowing a function to do lazy evaluation of its
> > operands.
> value = (lambda: valTrue, lambda: valFalse)[not selector]()
Of course you can do it that way. Now try explaining that syntax
to your average COBOL programmer attempting to learn a more
More information about the Python-list