[issue42456] Logical Error
Tim Peters
report at bugs.python.org
Wed Dec 9 01:29:09 EST 2020
Tim Peters <tim at python.org> added the comment:
Please ask for help on StackOverflow or the general Python mailing list. Your understanding of the operations is incorrect.
"&" is NOT a logical operator ("and" is). It's a bitwise operator on integers.
>>> 10 & 10
10
>>> bin(10)
'0b1010'
The last bit is 0, so when you "&" the result with True (which is equivalent to integer 1) the result is 0:
>>> (10 & 10) & True
0
and the integer 0 is treated as False in a Boolean context.
----------
resolution: -> not a bug
status: open -> closed
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue42456>
_______________________________________
More information about the Python-bugs-list
mailing list