On Sat, Dec 28, 2019 at 12:35 AM Chris Angelico <[email protected]> wrote:

> On Sat, Dec 28, 2019 at 7:03 PM Steve Barnes <[email protected]>
> wrote:
> >
> > Personally I still like the fundamental:
> >
> > def is_nan(num):
> >
> >     “”” Test for NaN “””
> >
> >     return num != num
> >
>
> Which was in Steven's original post, and which is dangerous because a
> signalling nan will bomb.


Indeed it will:

In [2]: sn = Decimal('snan')


In [3]: sn == sn

---------------------------------------------------------------------------
InvalidOperation                          Traceback (most recent call last)
<ipython-input-3-3f631717c061> in <module>
----> 1 sn == sn

InvalidOperation: [<class 'decimal.InvalidOperation'>]

and with a custom Exception from the Decimal module, so a bit annoying to
trap :-(

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/Z4LH3TXVP6IISKBVA4KHU4CTLYOZ3CUL/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to