substitute for c/java's ?:
Tomasz Stochmal
tom at peresys.co.za
Thu Jun 14 10:38:47 EDT 2001
> 1. (most important)
> I am missing something like the c/Java ?: operator. This is so convenient in
> many places and saves a lot of typing.
> It works like
> result = option ? value1 : value2;
> which is equivalent to
> if option:
> result = value1
> else:
> resultl = value2
>
> Is there anything I overlooked?
I use this function I wrote:
def iif(Condition,ValueTrue,ValueFalse):
if Condition:
return ValueTrue
else:
return ValueFalse
Example on in-line if:
result=iif(option,value1,value2)
More information about the Python-list
mailing list