[Python-Dev] Re: ternary operators (fwd)
Moshe Zadka
Moshe Zadka <mzadka@geocities.com>
Tue, 1 Feb 2000 07:51:08 +0200 (IST)
On Mon, 31 Jan 2000 gvwilson@nevex.com wrote:
> So I asked Simon Peyton-Jones and Phil Wadler how languages other than C
> and its derivatives did conditional expressions; one of the replies was:
<snipped>
> Perhaps this would be a good time to ask around and see what else people
> have in their back pockets?
Adding nothing to the discussion, let me just mention how Scheme (my
second favourite language) does it:
(if bool true-result else-result)
Well, of course this isn't relevant to Python because statements are not
expressions, but there might be something in it: if could be also used
as a function taking three arguments:
print if(long_answer, "Very good!", "correct")
I have no idea how this will play with the parser. Anyone?
--
Moshe Zadka <mzadka@geocities.com>.
INTERNET: Learn what you know.
Share what you don't.