[Python-Dev] Decimal & amp; lt; -& amp; gt; float comparisons in py3k.
R. David Murray
rdmurray at bitdance.com
Fri Mar 19 21:33:56 CET 2010
On Fri, 19 Mar 2010 12:16:35 -0700, Glenn Linderman <v+python at g.nevcal.com> wrote:
> On 3/19/2010 11:43 AM, Terry Reedy wrote:
> > 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?
> The same person that would expect both
> 0 == "0"
> 0.0 == "0.0"
> to be False... i.e. anyone that hasn't coded in Perl for too many years.
No, those two situations are not comparable.
"if a equals b and b equals c, then a equals c" is what most people
will expect. In fact, only mathematicians are likely to know
that any other situation could possibly be valid. Programmers are
generally going to view it as a bug.
R. David Murray www.bitdance.com
More information about the Python-Dev