On Sun, Jun 14, 2020 at 3:14 PM Sebastian M. Ernst <er...@pleiszenburg.de>
wrote:

>
> Am 14.06.20 um 14:56 schrieb Alex Hall:
> > It would help a lot if you could show some examples.
>
> There you go:
>
> > ```python
> >
> > import math
> > a = 1.0000000001
> > b = 0.9999999999
> >
> > print( a == b ) # prints "False"
> > print( math.isclose(a, b) ) # prints "True"
> >
> > class demo(float):
> >     # this could actually become `__ce__` or similar:
> >     def __mod__(self, other: float) -> bool:
> >         return math.isclose(self, other)
> >
> > ad = demo(a)
> > bd = demo(b)
> >
> > print( ad == bd ) # prints "False" as before
> >
> > # this could actually become `ad ~= bd` or similar:
> > print( ad % bd ) # prints "True"
> >
> > ```
>
> I hope this helps.
>

No, I mean show the difference in readability in real code with real logic,
or close to real. Show us the tests you refactored in two versions: with
math.isclose, and with `~=`.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/BGSMSXNQBSGVL7STGDBLI2CNNYQTP7EA/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to