datetime and the rich-companison operators

Chris Rebert clp at rebertia.com
Mon Dec 8 12:52:49 EST 2008


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

-- 
Follow the path of the Iguana...
http://rebertia.com

>
> Thanks in advance!
> ~ethan~
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list