In the Language Reference section 3.4.1 (http://docs.python.org/ref/customization.html for version 2.5), in the first paragraph where it describes __lt__, __le__, __eq__, __ne__, __gt__, and __ge__,
It should mention the special case of NotImplemented, so that people will not be reluctant to return it. (The fourth paragraph suggests returning NotImplemented, but the first suggests that *any* return value will be converted to a boolean, so that NotImplented would mean "True")
Please change:
"""These methods can return any value, but if the comparison operator is used in a Boolean context, the return value should be interpretable as a Boolean value, else a TypeError will be raised. By convention, False is used for false and True for true."""
to:
"""When an object does not know how to compute a meaningful result, it should return the singleton NotImplemented, in case the other object implements the reflected comparison.
By convention, a successful comparison should return either True or False. If any other object is returned in a Boolean context, python will implicitly call bool(result).
"""
|