(original) (raw)
>>> int(complex(2, 0))
Traceback (most recent call last):
File "", line 1, in
TypeError: can't convert complex to int
There could be an argument that a putative complex.is\_integral() should therefore return False, but I expect that would get even less support than the other suggestions in these threads.
I apologize that I get into the discussion. Obviously in some situations it will be useful to check that a floating-point
number is integral,
but from the examples given it is clear that they are very rare. Why the variant with the inclusion of this functionality into the math module was not considered at all. If the answer is - consistency upon the numeric tower - will it go for complex type and what will it mean (there can be two point of views)?
Is this functionality so often used and practical to be a method of float, int, ..., and not just to be an auxiliary function?
p.s.: The same thoughts about \`as\_integer\_ratio\` discussion.With kind regards,-gdg
\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: https://mail.python.org/mailman/options/python-dev/ rob%40sixty-north.com