Sven Marnach <s...@marnach.net> added the comment:

The behaviour discussed in this thread does not seem to be reflected in 
Python's documentation.  The documentation of __eq__() [1] doesn't mention that 
objects should compare equal to themselves.

 [1]: http://docs.python.org/dev/reference/datamodel.html#object.__eq__

There are several places in the documentation that are wrong for NaNs; just one 
example is the documentation of sequence types [2], which states:

> This means that to compare equal, every element must compare equal
> and the two sequences must be of the same type and have the same
> length.

 [2]: 
http://docs.python.org/dev/library/stdtypes.html#sequence-types-str-bytes-bytearray-list-tuple-range

It's probably not worthwhile to "fix" all the places in the documentation that 
implicitly assume that objects compare equal to themselves, but it probably is 
a good idea to mention that __eq__() implementations should fulfil this 
assumption to avoid strange behaviour when used in combination with standard 
containers.  Any thoughts?

----------
nosy: +smarnach

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue4296>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to