[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
priority: normal
severity: normal
status: open
title: Unexpected behavior of operator "in"
type: behavior
versions: Python 2.7, Python 3.5

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



[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 
<http://bugs.python.org/issue30965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[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 
<http://bugs.python.org/issue30965>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com