On 12/28/2019 5:39 AM, Antoine Pitrou wrote:
On Fri, 27 Dec 2019 23:52:13 -0800
Christopher Barker <[email protected]>
wrote:
On Fri, Dec 27, 2019 at 5:39 PM Guido van Rossum <[email protected]> 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.

functools.singledispatch() is another option. But then you need to decide where the base function lives, and how types are added to it.

Eric
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/LGNLWY5RR6LKLAWK5GU2BZZITOYO4EPK/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to