Mark Dickinson wrote: > On Tue, Feb 12, 2008 at 1:52 AM, Raymond Hettinger <[EMAIL PROTECTED]> wrote: > >> Also, it would be useful to have a new method, float.is_integer(). This >> would be better than the current approach where we make the >> test: if x == floor(x). >> > > How common is this test? Given the inexact nature of floating-point > arithmetic, checking whether a float is exactly an integer seems like > something that one might actually want to discourage, just like comparing > two floats for equality. > > Also, what about having float.is_finite, as a quicker way to spell "not > isinf(x) and not isnan(x)" > > +1 on making these methods of float; they're fundamental properties. > > Mark
Yes, and I don't know if this was mentioned, but should add to complex also. isfinite (complex_x): return isfinite (x.real) and isfinite (x.imag) _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com