Patches item #1602128, was opened at 2006-11-24 02:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1602128&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Jewett (jimjjewett)
Assigned to: Nobody/Anonymous (nobody)
Summary: clarify comparison return values

Initial Comment:
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).
"""

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1602128&group_id=5470
_______________________________________________
Patches mailing list
Patches@python.org
http://mail.python.org/mailman/listinfo/patches

Reply via email to