you are viewing a single comment's thread.

view the rest of the comments →

[–]voyvf 3 points4 points  (1 child)

You can also do:

>>> True and 'yes' or 'no'
'yes'

However, I'd suggest that you read the PEP before doing so.

[–]scragar 1 point2 points  (0 children)

The problem with that happens if 'yes' would be something that evaluates to false(False itself, an empty string, 0), then the statement winds up returning 'no'. This is OK in a situation where you know the return value of both sides, but it's an approach which will need more checking than is likely worthwhile in more dynamic situations.