Comment on Ternary operator in Python

Mark
Sat, 17 Jul 2010 01:40:51 +0000

Since Python 2.5 you can do ternary operations like so:

f() if h() else g()

http://docs.python.org/reference/expressions.html

Dive into Python also gives a good overview of solving it the long way: