I'm trying to figure out how the 'or' operator works in python when used on variables that are not boolean. In particular, I'm puzzled by the fact that it seems to be non-commutative. Shouldn't 'or' be commutative?
From what I can tell it seems to be implementing:
a or b = a, unless a = null or 0, then a or b = b.
Examples:
> 0 or 5
5
> 5 or 3
5
> 3 or 5
3
> '' or 5
5
> 5 or ''
5
> 'ab' or 'cd'
'ab'
> 'cd' or 'ab'
'cd'
> '' or 'cd'
'cd'