[Python-ideas] PEP 485: A Function for testing approximate equality

Ron Adam ron3200 at gmail.com
Fri Feb 6 07:36:13 CET 2015



On 02/06/2015 12:12 AM, Andrew Barnert wrote:
> On the other hand, I think (as you hint later) that it might be better just
> to not try to make the point formally in the PEP.

And it's a whole lot simpler to write...

        if isclose(x, y):
             ...

instead of...

        if y - y * 1e-8 <= x <= y + y * 1e-8:
             ...


I think the isclose() line is much easier to read!

And the function will probably get it right, where I may get one of the 
signs reversed, or make some other silly error in the expression.

So +1 from me.

Cheers,
    Ron



More information about the Python-ideas mailing list