A = X > Y ? X : Y
Stidolph, David
stidolph at origin.ea.com
Wed Feb 9 11:57:12 EST 2000
I would think that this would be better because it eliminates a local
variable assignment.
def iif( condition, first, second ):
if condition:
return first
else:
return second
-----Original Message-----
From: Michal Wallace [mailto:sabren at manifestation.com]
Sent: Wednesday, February 09, 2000 8:46 AM
To: python-list at python.org
Subject: Re: A = X > Y ? X : Y
Curtis Jensen wrote in message <38A0BD01.9586107B at be-research.ucsd.edu>...
>I fear that this question has already been asked, but is there and
>equivalant one line command that is equivalant to the C command:
>
>a = x > y ? x : y
I know there's been a couple replies to this... but why not do something
like
VB's (or at least VBA's - not sure if VB proper has it) "immediate If"
function?
def iif( condition, first, second ):
result = second
if condition:
result = first
return result
then it's:
a = iif( a > y, x, y )
-michal
http://www.sabren.com/
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list