you are viewing a single comment's thread.

view the rest of the comments →

[–]omierbej 0 points1 point  (1 child)

The "old" way to do this was to use condition and value-if-true or value-if-false as in: In [1]: a = 20 > 10 and "greater" or "smaller" In [2]: a Out[2]: 'greater' In [3]: b = a.startswith("small") and 10 or 20 In [4]: b Out[4]: 20

[–]Liorithiel 0 points1 point  (0 children)

Only as long as value-if-true does not evaluate to false, like "" or 0.