This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ztane
Recipients docs@python, ztane
Date 2017-07-19.11:55:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1500465353.64.0.619810995706.issue30969@psf.upfronthosting.co.za>
In-reply-to
Content
The doc reference/expressions.srt says that

> For user-defined classes which do not define __contains__() but do 
> define __iter__(), x in y is True if some value z with x == z is 
> produced while iterating over y. If an exception is raised during the 
> iteration, it is as if in raised that exception.

and

> Lastly, the old-style iteration protocol is tried: if a class defines 
> __getitem__(), x in y is True if and only if there is a non-negative 
> integer index i such that x == y[i], and all lower integer indices do 
> not raise IndexError exception. (If any other exception is raised, it 
> is as if in raised that exception).

The documentation doesn't match the implementation, which clearly does `x is y or x == y` to check if `x` is the element `y` from a container. Both the `__iter__` and the index-iteration method test the elements using `is` first. While the document says that `x is x` means that `x == x` should be true, it is not true for example in the case of `nan`:
History
Date User Action Args
2017-07-19 11:55:53ztanesetrecipients: + ztane, docs@python
2017-07-19 11:55:53ztanesetmessageid: <1500465353.64.0.619810995706.issue30969@psf.upfronthosting.co.za>
2017-07-19 11:55:53ztanelinkissue30969 messages
2017-07-19 11:55:53ztanecreate