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

Shabda Raaj shabda at agiliq.com
Tue Sep 10 07:40:38 CEST 2013


Eg: See this:

http://nbviewer.ipython.org/5151306

I was expecting datetime.date.today() == datetime.datetime.today()

to give me a True. (It is false).

For example this works as I expect:

http://nbviewer.ipython.org/5151398

However looks like __eq__ is doing a isinstance check - I would expect
things which are "duck-type" equal to pass the __eq__ check.

http://hg.python.org/cpython/file/5fb700ca3fd5/Lib/datetime.py

-- 
Thanks,
Shabda

Agiliq.com - Building Amazing Apps
agiliq.com/blog/ | github.com/agiliq
US: +13152854388 | IN: +919949997612 | Skype: shabda.raaj
Our Android Apps <https://play.google.com/store/apps/developer?id=Agiliq> | Our
iOS Apps <https://itunes.apple.com/us/artist/agiliq/id407918088>


More information about the BangPypers mailing list