Possible Duplicate:
Conditional operator in Python?
Is there a c-like operator in python that check if a condition holds and assign a value accordingly?
<condition> ? <operation> : <operation>
Possible Duplicate:
Conditional operator in Python?
Is there a c-like operator in python that check if a condition holds and assign a value accordingly?
<condition> ? <operation> : <operation>
 
    
    The syntax is different in Python.
<operation> if <condition> else <operation>
For example,
x = max(y, z)
is roughly the same as:
x = z if z > y else y
 
    
    One of Python's design philosophies seems to be to use words instead of symbols when possible. In this case, the best words to use are if and else. But those words are already taken. So Python cheats a bit and uses syntax to disambiguate the version of if that controls flow from the version of if that returns a value. 
