[BangPypers] Should equality (__eq__) be dependent on the typeof object?

Noufal Ibrahim noufal at nibrahim.net.in
Tue Sep 10 08:00:20 CEST 2013


Shabda Raaj <shabda at agiliq.com> writes:

>> I'd expect it to be False. There will be a small amount of time between
> the two invocations and the time will change
>
> Ok, that makes sense. Should have written a better test case. What about
> this.
>
>>>> datetime.datetime(2013, 1, 1) == datetime.date(2013, 1, 1)
> False
>>>> datetime.datetime.today() == datetime.date.today()
> False

I think that's reasonable. 

"Today" (10/Sep) is not equal to "right now" (10/Sep, 11:28 am).

Makes sense no? 

However, 

>>> x, y = datetime.datetime(2013, 1, 1), datetime.date(2013, 1, 1)
>>> x.date() == y
True

which is much more sensible. 

For what it's worth, I think this whole business of dates and times is a
mess.


-- 
Cordially,
Noufal
http://nibrahim.net.in


More information about the BangPypers mailing list