I've been tinkering a little with Python operators and came across something I'm not sure about.
If I perform a bitwise operation (&, |) on 2 integers I will get unsurprisingly their bitwise value
.
Meaning:
>>> a = 11
>>> b = 3
>>> a & b
3
This is because bitwise and performs and on the binary representation of this numbers. However, if I use the built in and operator I will get the second variable, irrespective of it's type:
>>> b and a
11
>>> 'b' and 'a'
'a'
Why is it so?