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

gene tani gene.tani at gmail.com
Sun Jun 19 09:48:15 EDT 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

http://www.norvig.com/python-iaq.html




More information about the Python-list mailing list