[New-bugs-announce] [issue23986] Inaccuracy about "in" keyword for list and tuple

wim glenn report at bugs.python.org
Fri Apr 17 09:22:58 CEST 2015

New submission from wim glenn:

The comparisons section of the python 2 docs says:



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.


But it's not strictly speaking correct.  Simplest counter-example:

x = float('nan')
y = [x]

The python 3 docs instead mention correct equivalent which is 

any(x is e or x == e for e in y)

assignee: docs at python
components: Documentation
messages: 241317
nosy: docs at python, wim.glenn
priority: normal
severity: normal
status: open
title: Inaccuracy about "in" keyword for list and tuple
type: enhancement
versions: Python 2.7

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list