classification
Title: Conditionals not evaluating propertly
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Segebre, serhiy.storchaka
Priority: normal Keywords:

Created on 2018-04-26 07:02 by Segebre, last changed 2018-04-26 07:05 by serhiy.storchaka. This issue is now closed.

Messages (2)
msg315779 - (view) Author: Juan Enrique Segebre Zaghmout (Segebre) Date: 2018-04-26 07:02
The following code generates False when it should generate true:

True == False < 20

Either way the order of operation is taken should result in True but the answer still results in False. To further confirm this issue I did a simple test in which we would group the operations, the test uses print statements to visualize results. The short following code represents the above conditional and the two order of operations possibilities.

print(True == False < 20);
print((True == False) < 20);
print(True == (False < 20));

This yields the following output:

False
True
True

Proving the bug. To explain even further, the code shall be interpreted in either of the following two ways:
1. True == False < 20
   False < 20
   True

2. True == False < 20
   True == True
   True

In either case the result is True, yet python yields False.
msg315781 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-26 07:05
In Python "True == False < 20" is evaluated as "True == False and False < 20". See https://docs.python.org/3/reference/expressions.html#comparisons
History
Date User Action Args
2018-04-26 07:05:50serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg315781

resolution: not a bug
stage: resolved
2018-04-26 07:02:07Segebrecreate