[ python-Bugs-1673403 ] date-datetime comparison doesn't work
SourceForge.net
noreply at sourceforge.net
Sun Mar 4 12:51:23 CET 2007
Bugs item #1673403, was opened at 2007-03-04 11:51
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1673403&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jon Ribbens (jribbens)
Assigned to: Nobody/Anonymous (nobody)
Summary: date-datetime comparison doesn't work
Initial Comment:
Summary: bug #1028306 was not a bug, but the fix for it introduced one
Comparing a date to a datetime currently throws an exception. This makes no sense. In what way is:
datetime(2006, 1, 1, 0, 0, 0) < date(2007, 1, 1)
not a perfectly reasonable and well-defined comparison? Throwing an exception here violates the "Principle of Least Surprise" to a considerable degree.
Obviously some slight ambiguity arises if the date and the datetime differ only in the time part. There are two sensible responses in this situation that I can see:
Treat dates as if they have a time-part of midnight. This is my preferred solution, and it is already what the datetime module does, for example, when subtracting two dates.
Treat dates as if they refer to the entire day, i.e. if the date and datetime differ only in the time part then they are equal. This is consistent but becomes confusing in other situations such as when subtracting dates.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1673403&group_id=5470
More information about the Python-bugs-list
mailing list