On 3/19/2010 2:11 PM, Antoine Pitrou wrote:
Raymond Hettinger<raymond.hettinger<at> gmail.com> writes:
The reason to prefer an exception is that decimal/float comparisons
are more likely to be a programmer error than an intended behavior.
If you really believe that, then equality comparisons should also be
disabled by raising NotImplemented or whatever. Clearly, someone who
writes 'if somefloat == somedecimal:'assumes (now wrongly) that the test
might be true. This is just as buggy as an order comparison. Raising an
exception would consistently isolate decimals from other numbers and
eliminate the equality intransitivity mess and its nasty effect on sets.
It still strikes me as a bit crazy for Python to say that 0.0 == 0 and 0
== Decimal(0) but that 0.0 != Decimal(0). Who would expect such a thing?
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com