• Tim Peters's avatar
    Comparison for timedelta, time, date and datetime objects: __eq__ and · 07534a60
    Tim Peters yazdı
    __ne__ no longer complain if they don't know how to compare to the other
    thing.  If no meaningful way to compare is known, saying "not equal" is
    sensible.  This allows things like
    
        if adatetime in some_sequence:
    and
        somedict[adatetime] = whatever
    
    to work as expected even if some_sequence contains non-datetime objects,
    or somedict non-datetime keys, because they only call __eq__.
    
    It still complains (raises TypeError) for mixed-type comparisons in
    contexts that require a total ordering, such as list.sort(), use as a
    key in a BTree-based data structure, and cmp().
    07534a60
datetimemodule.c 129 KB