Is there something similar to ?: operator (C/C++) in Python?

gene tani gene.tani at
Sun Jun 19 15:48:15 CEST 2005

If your test variable has specific values to branch on, the standard
way is to have those values be keys in a dictionary, and do:

branched_func_obj = dict_of_values.get(testvar)

And the lambda hack is here, courtesy of Peter Norvig

More information about the Python-list mailing list