[Python-ideas] datetime module enhancements

Steven Bethard steven.bethard at gmail.com
Mon Mar 12 18:42:21 CET 2007

On 3/12/07, Christian Heimes <lists at cheimes.de> wrote:
> datetime before date: <
> datetime during date: in
> datetime after date: >

> datetime <= date and datetime => date should raise a TypeError. The
> result is ambiguous. A date with time is never equal to a date.

Jim Jewett wrote:
> As a practical matter, sorting uses <=

Are you sure?

    >>> class C(object):
    ...     def __init__(self, x):
    ...         self.x = x
    ...     def __lt__(self, other):
    ...         return self.x < other.x
    ...     def __le__(self, other):
    ...         raise TypeError()
    ...     def __repr__(self):
    ...         return 'C(%r)' % self.x
    >>> sorted([C(3), C(2), C(1)])
    [C(1), C(2), C(3)]

Looks like it's just using < to me.

(And thanks to Collin and Christian for jumping on the patch already.)

I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a
tiny blip on the distant coast of sanity.
        --- Bucky Katt, Get Fuzzy

More information about the Python-ideas mailing list