Post AY6UNPhvaG9UILbvHM by nedbat@hachyderm.io
 (DIR) More posts by nedbat@hachyderm.io
 (DIR) Post #AY5iO5Nnq9CxkVS63U by nedbat@hachyderm.io
       2023-07-26T15:39:06Z
       
       0 likes, 0 repeats
       
       Opinions? Should this produce a #Python syntax warning?   if x == 2 or 3:https://discuss.python.org/t/can-we-make-a-syntaxwarning-for-if-x-2-or-3/30263
       
 (DIR) Post #AY5iO6HoTu0kYDepMG by nedbat@hachyderm.io
       2023-07-26T15:40:50Z
       
       1 likes, 0 repeats
       
       As an example, since Python 3.11, this happens:>>> if x is 1: pass...<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
       
 (DIR) Post #AY6UNOkj8MnTKjue0G by vstinner@mamot.fr
       2023-07-26T17:26:21Z
       
       0 likes, 0 repeats
       
       @nedbat i fail to recall operator priority between C, Python and other programming languages, so I aggressively add parenthesis to make sure that the computer does what I'm thinking about :-) "if x == (2 or 3)" or "if (x == 2) or 3". What about "if x == 2 | 3", which operator wins? :-) I would prefer to write "if x == (2 | 3)". GCC emits warnings on ambiguous code, suggesting to add parenthesis.
       
 (DIR) Post #AY6UNPhvaG9UILbvHM by nedbat@hachyderm.io
       2023-07-26T17:53:41Z
       
       0 likes, 0 repeats
       
       @vstinner The beginner meant `if x == (2 or 3)`, but that won't do what they want (as you know).
       
 (DIR) Post #AY6UNQI5Pp4k6UWndg by graham_knapp@hachyderm.io
       2023-07-26T18:10:14Z
       
       0 likes, 0 repeats
       
       @nedbat @vstinner couldn't resist this one... (yes, I know)
       
 (DIR) Post #AY6UNRCo0wRgwP462y by moshez@mastodon.social
       2023-07-26T19:56:06Z
       
       1 likes, 0 repeats
       
       @graham_knapp @nedbat @vstinner