[issue18842] Add float.is_finite is_nan is_infinite to match Decimal methods
Steven D'Aprano
report at bugs.python.org
Sun Jan 29 06:01:18 EST 2017
Steven D'Aprano added the comment:
On Sun, Jan 29, 2017 at 08:23:05AM +0000, Martin Panter wrote:
> Why do you name the methods is_finite() etc with underscores, when the
> existing methods math.isfinite() etc do not have underscores? Seems it
> would add unnecessary confusion.
The idea is to enable duck-typing between float and Decimal. Instead of:
if isinstance(x, float):
math.isfinite(x)
else:
x.is_finite()
we can just say
x.is_finite()
on both floats and decimals.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18842>
_______________________________________
More information about the Python-bugs-list
mailing list