Hi all, after just having typed tons of `math.isclose` (see PEP 485 [1]) and `numpy.isclose` calls (while basically using their default tolerances most of the time), I was wondering whether it makes sense to add a matching operator.
"Strict" equality check as usual: `a == b` "Approximate" equality check: -> `a ?= b` (similar to `!=`) -> `a ~= b` (my preference) -> `a === b` (just to confuse the JS crowd) A corresponding method could for instance be named `__ic__` (Is Close), `__ae__` (Approximate Equal) or `__ce__` (Close Equal). It's such a common problem when dealing with floating point numbers or similar data types (arrays of floats, float-based geometries etc). An operator of this kind would make many people's lives much easier, I bet. I have overloaded the modulo operator in some test code and it actually helps a lot to make some logic more readable. Best regards, Sebastian 1: https://www.python.org/dev/peps/pep-0485/ _______________________________________________ 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/KD45D5JKJS72PF7NRHC4MMQQEOB7MLRX/ Code of Conduct: http://python.org/psf/codeofconduct/