On Sun, Jun 14, 2020 at 3:14 PM Sebastian M. Ernst
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 `~=`.