[Python-Dev] Mixed-type datetime comparisons

M.-A. Lemburg mal@lemburg.com
Sat, 25 Jan 2003 18:39:19 +0100


Tim Peters wrote:
> I checked in changes so that datetime and date comparison return
> NotImplemented (instead of raising TypeError) if "the other" argument has a
> timetuple attribute.  This gives other kinds of datetime objects a chance to
> intercept the comparison and implement it themselves.

Nice.

> Note that this doesn't help for mixed-type time or timedelta comparison:
> datetime's time and timedelta objects don't have timetuple methods
> themselves, and their comparison implementations still raise TypeError
> whenever they don't recognize the other comparand's type (this is needed to
> prevent comparison against objects of arbitrary types from falling back to
> the default comparison of object addresses).

Why not add them (setting the date parts to None) ?

-- 
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting:                               http://www.egenix.com/
Python Software:                    http://www.egenix.com/files/python/