datetime and the rich-companison operators

Ethan Furman ethan at stoneleaf.us
Mon Dec 8 21:38:33 CET 2008


Chris Rebert wrote:
> On Sun, Dec 7, 2008 at 11:41 PM, Ethan Furman <ethan at stoneleaf.us> wrote:
> 
>>Greetings All!
>>
>>I am implementing a NullDate class in order to mirror dates and datetimes
>>that have no value  (yes, this is for my dbf  module :)
>>
>>I'm still a bit fuzzy about class methods, hashing, and __new__, but my
>>question of the moment is this:  it seems to me that with two dates or
>>datetimes, they should either be equal, or one should precede the other, and
>>this can be accomplished quite handily with __cmp__... so does anyone know
>>why the rich comparisons were used in the datetime module? Was it simply a
>>style choice, or is something being handled that __cmp__ couldn't cope with?
> 
> 
> Probably because __cmp__ was removed in Python 3.0, thus requiring the
> use of the rich comparison methods in its place.
> See the earlier thread entitled "Python 3 __cmp__ semantic change?".
> 
> Cheers,
> Chris
> 

Thanks, Chris!
~ethan~



More information about the Python-list mailing list