Hi,
I need to pass a bunch of parameters conditionally. In C/C++, I can do
func(cond1?a:b,cond2?c:d,.....)
In Python, I am using temporary variables like
if cond1:
para1 = a
else:
para1 = b
# ....
# a bunch of such if/else
func(para1, para2,...)
Is there an easier way to do this in Python?
BTW, I do not want to use the following since all of a,b,c,d etc will be
evaluated.
def condValue(cond, val1,val2):
if cond:
return val1
else:
return val2
func(condValue(cond1,a,b), condValue(cond2,c,d),...)
Thanks.
Bo
--
http://mail.python.org/mailman/listinfo/python-list