["python","conditional-operator","language-features"]
Conditional/ternary operator for expressions in Python

Many languages have a conditional (AKA ternary) operator. This allows you to make terse choices between two values based on a condition, which makes expressions, including assignments, concise. My code has conditional assignments: if condition: var = something else: var = something_else In C it'd be: var = condition ? something : something_else; In Python, is there a trick you can use to get the assignment onto a single line to approximate the advantages of the conditional operator?
Python has such an operator: variable = something if condition else something_else Alternatively, although not recommended (see karadoc's comment): variable = (condition and something) or something_else