[issue38060] precedence (relational, logical operator)not working with single value

2019-09-08 Thread Sangeeta M Chauhan


New submission from Sangeeta M Chauhan :

precendence betweeen relational and logical operators not working properly if 
expression contains single values instead of sub expressions. . Please see 
attached file

--
components: Interpreter Core
files: pythonBug.py
messages: 351344
nosy: sangeetamchauhan
priority: normal
severity: normal
status: open
title: precedence (relational,logical operator)not working with single value
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file48600/pythonBug.py

___
Python tracker 
<https://bugs.python.org/issue38060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38060] precedence (relational, logical operator)not working with single value

2019-09-08 Thread Sangeeta M Chauhan


Sangeeta M Chauhan  added the comment:

i am not satisfied ..with your answer . as in the following expression   9
or 7 > "str" precedence must be given to relational operator . why is is
executing logical operator first??
if we write  4>9 or 7> "str" it works correct but if we replace first
condition(4>9) with a numeric value it is not giving correct output

On Mon, Sep 9, 2019 at 9:25 AM Tim Peters  wrote:

>
> Tim Peters  added the comment:
>
> It's working fine.  What do you expect?  For example,
>
> 9 or 7 > "str"
>
> groups as
>
> 9 or (7 > "str")
>
> 9 is evaluated for "truthiness" first, and since it's not 0 it's
> considered to be true.  That's enough to determine the result of "or", so
> (7 > "str") isn't evaluated at all.  9 is the result.
>
> This is all working as designed and as documented, so I'm closing this
> report.
>
> --
> nosy: +tim.peters
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38060>
> ___
>

--
title: precedence (relational,logical operator)not working with single value -> 
precedence (relational, logical operator)not working with single value

___
Python tracker 
<https://bugs.python.org/issue38060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38060] precedence (relational, logical operator)not working with single value

2019-09-10 Thread Sangeeta M Chauhan


Sangeeta M Chauhan  added the comment:

Sir, I was expecting that the precedence should be given to relational
operator (  7>"str")   and according to that instead of printing 9 it
should give error.

On Mon, Sep 9, 2019 at 8:38 PM Tim Peters  wrote:

>
> Tim Peters  added the comment:
>
> @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.
>
> --
>
> ___
> Python tracker 
> <https://bugs.python.org/issue38060>
> ___
>

--

___
Python tracker 
<https://bugs.python.org/issue38060>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com