A common Python idiom is to assign a variable using the return value of a logic expression:
>>> a = 0
>>> b = a or -1
>>> b
-1
That is (for a
understood to be an integer): "set b
equal to the value of a
unless a==0
, in which case set b
equal to -1
''.