On Mar 19, 2010, at 11:11 AM, 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.
> 
> Not more so than float/int or decimal/int or bool/int comparisons, which all 
> work.

The float/int and decimal/int comparisons have valid and common use cases.
In contrast, comparing binary floats and decimal floats is rare, and more 
likely to be an accident.

When an int is converted to a float or decimal, the result usually isn't
surprising.  The conversion of a float to a decimal is not as straight-forward
(most people don't even know that an exact conversion is possible).

Also, the float and decimal constructors also natively accept ints as inputs,
but the decimal constructor intentionally excludes a float input.


Raymond



_______________________________________________
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

Reply via email to