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 terry.reedy
Recipients brett.cannon, terry.reedy
Date 2020-10-03.01:43:58
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1601689438.59.0.230854251145.issue41911@roundup.psfhosted.org>
In-reply-to
Content
For rich comparisons, a proper explanation is given in the rich comparison entry in the datamodel section ( #41910) 

"A rich comparison method may return the singleton NotImplemented if it does not implement the operation for a given pair of arguments. By convention, False and True are returned for a successful comparison. However, these methods can return any value, so if the comparison operator is used in a Boolean context (e.g., in the condition of an if statement), Python will call bool() on the value to determine if the result is true or false."

bool(x) calls x.__bool__ and requires that the latter return False or True.

As for the other two comparisons, x is y always returns False or True for a proper implementation because int == int always does.  If y.__contains__(x) does not raise, x in y returns bool(y.__contains__(x)), clamping aberrant implementations of __contains__.

A replacement text might be 

"Comparisons normally yield boolean values: True or False.  But rich comparisons not in a Boolean context may yield anything."

Possibly link 'rich comparisons' to the datamodel section.
History
Date User Action Args
2020-10-03 01:43:58terry.reedysetrecipients: + terry.reedy, brett.cannon
2020-10-03 01:43:58terry.reedysetmessageid: <1601689438.59.0.230854251145.issue41911@roundup.psfhosted.org>
2020-10-03 01:43:58terry.reedylinkissue41911 messages
2020-10-03 01:43:58terry.reedycreate