This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients sangeetamchauhan, steven.daprano, tim.peters
Date 2019-09-09.15:08:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568041705.58.0.756090980018.issue38060@roundup.psfhosted.org>
In-reply-to
Content
@sangeetamchauhan, the reply you got in the image you attached was in error - kind of.  Section "6.16. Operator precedence" defines Python's operator precedence:

https://docs.python.org/3/reference/expressions.html#index-92

"""
The following table summarizes the operator precedence in Python, from lowest precedence (least binding) to highest precedence (most binding).
"""

As you can see there, "and" and "or" are very near the top of the table, so bind very weakly - almost anything else on either side gets evaluated first.  In particular, all comparison operators bind more tightly than "and" and "or".

It's the bitwise operators (| & ^) that bind more tightly than comparisons.

I asked at the start "What do you expect?" but you never answered.  You just keep repeating that it's wrong.  Sorry, but I still have no idea what you think "should" happen instead.

As I also said the start,

    9 or 7 > "str"

groups as

    9 or (7 > "str")

exactly as the operator precedence table says it should, and returns 9, exactly as the docs for "or" say it should do.

What about that do you think is wrong?  Please be very specific, and back your answer with a reference to what the docs actually say.
History
Date User Action Args
2019-09-09 15:08:25tim.peterssetrecipients: + tim.peters, steven.daprano, sangeetamchauhan
2019-09-09 15:08:25tim.peterssetmessageid: <1568041705.58.0.756090980018.issue38060@roundup.psfhosted.org>
2019-09-09 15:08:25tim.peterslinkissue38060 messages
2019-09-09 15:08:25tim.peterscreate