News for hackers. Stuff that matters.
Re:Parse, don’t type-check by zelphirkalt on Friday November 27, 2020 @10:33AM (#25229435)
I don't see anything surprising. "is" has higher prevalenz than "in" and that's it. Or am I misreading something?
Re:Parse, don’t type-check by vanni on Friday November 27, 2020 @10:58AM (#25229687)
It's not a matter of operator precedence for two reasons:

1) "in" and "is" have same precedence, and group left to right (see https://docs.python.org/3/reference/expressions.html#operato...)

2) you'll have runtime error:

  In [1]: def c():
     ...:     return (1 in ([1,2,3] is True))
  
  In [2]: c()
  ...  
  TypeError: argument of type 'bool' is not iterable
It seems related to CPython bytecode compiler implementation, the two functions are parsed in a different way, parentheses make the compiler go on a different path... but I'd like to understand why, without diving into CPython source code :) Anyone?
Re:Parse, don’t type-check by morelisp on Friday November 27, 2020 @02:34PM (#25231884)
If this was the reason you'd get a TypeError, since there's no `bool.__contains__`.