[issue4087] equality involving Decimals is not transitive; strange set behaviour results

Facundo Batista report at bugs.python.org
Thu Oct 9 19:05:06 CEST 2008


Facundo Batista <facundo at taniquetil.com.ar> added the comment:

(Ok, remember that I'm not a "numeric" guy before start hitting me, :p )

I think that if we have Decimal(1)==1, and 1==1.0, to have Decimal(1)==1.0.

We always rejected comparison with "unsupported types", but having this
situation, I'd propose to put something like the following at the
beggining of __eq__() and similars:

    def __eq__(self, other):
        if isinstance(other, float) and int(other)==other:
            other = int(other)

What do you think?

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4087>
_______________________________________


More information about the Python-bugs-list mailing list