The Ternary operator mentioned is only available from Python 2.5. From the WeekeePeedeea:
Though it had been delayed for several
years by disagreements over syntax, a
ternary operator for Python was
approved as Python Enhancement
Proposal 308 and was added to the 2.5
release in September 2006.
Python's ternary operator differs from
the common ?: operator in the order of
its operands; the general form is op1
if condition else op2
. This form
invites considering op1 as the normal
value and op2 as an exceptional case.
Before 2.5, one could use the ugly
syntax (lambda x:op2,lambda
x:op1)[condition]()
which also takes
care of only evaluating expressions
which are actually needed in order to
prevent side effects.