On Fri, 27 Dec 2019 23:52:13 -0800 Christopher Barker <python...@gmail.com> wrote: > On Fri, Dec 27, 2019 at 5:39 PM Guido van Rossum <gu...@python.org> wrote: > > > Is duck typing float or Decimal worth the bother? Barring that it could be > > done with some isinstance() checks (in the user code, not in math.isnan()). > > > > well, for the topic at hand in another thread -- in the statistics module. > And I was coming to the same conclusion, but it dawned on me that another > option would be to add a .is_nan() method to floats. (same as Decimal).
+1 for a .is_nan() method on suitable types. That's the most natural and elegant solution, IMHO. Tricks like "x == x" are nice when you *know* that x is a float or Decimal, but not in the general case. Regards Antoine. _______________________________________________ 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/2QMBOG7I3UW6N6L2YJLGPAP37NVBJTOD/ Code of Conduct: http://python.org/psf/codeofconduct/