NaN comparisons - Call For Anecdotes

Chris Angelico rosuav at gmail.com
Wed Jul 9 08:52:32 CEST 2014


On Wed, Jul 9, 2014 at 4:43 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> I don't understand this. You've just shown an example from Python 2 where
> 'in' uses 'is'. How is that a Python 3 change?

A docs change.

https://docs.python.org/2/reference/expressions.html#not-in
"""
For the list and tuple types, x in y is true if and only if there
exists an index i such that x == y[i] is true.
"""

https://docs.python.org/3/reference/expressions.html#not-in
"""
For container types such as list, tuple, set, frozenset, dict, or
collections.deque, the expression x in y is equivalent to any(x is e
or x == e for e in y).
"""

So the definition of the operator (as stated in the docs) has changed
to match its behaviour. That's definitely a change; the Py2 behaviour
is buggy according to its docs. Should the Py2 docs be updated to
match the Py3 docs, or should it be left as a minor technical
distinction that almost never is important?

ChrisA



More information about the Python-list mailing list