[issue30965] Unexpected behavior of operator "in"

2017-07-19 Thread Mihai Cara
Mihai Cara added the comment: I am sure that some time ago I read that `in` is a comparison operator but I forgot it and I was thinking that (x in y) would be equivalent to (replaced with) the return value of y.__contains__(x). -- ___ Python tracker

[issue30965] Unexpected behavior of operator "in"

2017-07-19 Thread Mihai Cara
Mihai Cara added the comment: Thank you! It was my fault: I was not expecting `in` to be a comparison operator. -- ___ Python tracker ___ ___

[issue30965] Unexpected behavior of operator "in"

2017-07-18 Thread Tim Peters
Tim Peters added the comment: Not a bug. For an explanation, I just answered a very similar question on StackOverflow: https://stackoverflow.com/questions/45180899/unexpected-result-from-in-operator/45180967#45180899 -- nosy: +tim.peters ___ Python

[issue30965] Unexpected behavior of operator "in"

2017-07-18 Thread Ammar Askar
Ammar Askar added the comment: Sorry, forgot the actual link. https://docs.python.org/3/reference/expressions.html#operator-precedence -- ___ Python tracker ___

[issue30965] Unexpected behavior of operator "in"

2017-07-18 Thread Ammar Askar
Ammar Askar added the comment: Check out this section of the documentation, notably this part: "Note that comparisons, membership tests, and identity tests, all have the same precedence and have a left-to-right chaining feature" Chaining lets you write stuff like this: >>> x = 1 >>> 0 < x < 2

[issue30965] Unexpected behavior of operator "in"

2017-07-18 Thread Mihai Cara
New submission from Mihai Cara: Unexpected behavior of operator "in" when checking if a list/tuple/etc. contains a value: >>> 1 in [1] is True False >>> (1 in [1]) is True True Is this a bug? If not, please explain why first variant return False. -- messages: 298633 nosy: mcara priorit