[Python-Dev] Issue 2736: datetimes and Unix timestamps

Terry Reedy tjreedy at udel.edu
Tue Jun 5 23:48:28 CEST 2012


On 6/5/2012 3:17 PM, Guido van Rossum wrote:
> On Tue, Jun 5, 2012 at 12:15 PM, Alexander Belopolsky
> <alexander.belopolsky at gmail.com> wrote:
>> On Tue, Jun 5, 2012 at 3:01 PM, Antoine Pitrou<solipsis at pitrou.net> wrote:
>>> You could say the same about equally "confusing" results, yet equality never
>>> raises TypeError (except between datetime instances):
>>>>>>>>> () == []
>>> False
>>>> And even closer to home,
>>>>>>> date(2012,6,1) == datetime(2012,6,1)
>> False
>>>> I agree, equality comparison should not raise an exception.
>> Let's make it so.

3.3 enhancement or backported bugfix? The doc strongly suggests that 
rich comparisons should return *something* and by implication, not 
raise. In particular, return NotImplemented instead of raising a 
TypeError for mis-matched arguments.
"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,"
-- 
Terry Jan Reedy


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /