Operator Precedence/Boolean Logic
Christian Gollwitzer
auriocus at gmx.de
Wed Jun 22 02:26:30 EDT 2016
Am 22.06.16 um 05:40 schrieb Elizabeth Weiss:
> I am a little confused as to how this is False:
>
> False==(False or True)
>
> I would think it is True because False==False is true.
>
> I think the parenthesis are confusing me.
Are you thinking, by any chance, that "or" indicates a choice? Comparing
False to either False "or" True? That is not the case.
"or" is an operator. "False or True" is *computed* and gives True, which
is then compared to False by "==". Python works in these steps:
1) False == (False or True)
2) False == (True)
3) False
Christian
More information about the Python-list
mailing list