[BangPypers] Should equality (__eq__) be dependent on the typeof object?
Noufal Ibrahim
noufal at nibrahim.net.in
Tue Sep 10 08:05:52 CEST 2013
Noufal Ibrahim <noufal at nibrahim.net.in> writes:
> 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).
You'd also get into a 'wat' if
10/Sep 11:30 == 10/Sep
and
10/Sep 15:30 == 10/Sep
but then,
10/Sep 11:30 != 10/Sep 15:30
Explicit is better than implicit after all.
[...]
--
Cordially,
Noufal
http://nibrahim.net.in
More information about the BangPypers
mailing list