[Python-Dev] Re: ternary operators (fwd)

David Ascher da@ski.org
Mon, 31 Jan 2000 21:33:41 -0800


From: <gvwilson@nevex.com>

> > > > d <c> e
> Replace '<' and '>' with the symbols of your choice --- embedding the
> conditional in the middle is still an interesting idea...

Which brings us back to if and else:

a = condition ? truecase : falsecase

would be

a = truecase if condition else falsecase

What's unintuitive at this point is the shortcutting, assuming that it would
still apply.  'condition' would get evaluated before truecase, and truecase
might not get evaluated at all.  Still, it 'reads' good to me. Not sure it's
all that Pythonic though.

--david