Is there something similar to ?: operator (C/C++) in Python?
Peter Hansen
peter at engcorp.com
Sat Jun 18 20:55:33 EDT 2005
Bo Peng wrote:
> I need to pass a bunch of parameters conditionally. In C/C++, I can do
> func(cond1?a:b,cond2?c:d,.....)
>
> Is there an easier way to do this in Python?
Please read the FAQ to learn the answer and much other useful
information. In this case, the specific entry follows, but you'd do
well to read all the entries:
http://www.python.org/doc/faq/programming.html#is-there-an-equivalent-of-c-s-ternary-operator
-Peter
More information about the Python-list
mailing list