(original) (raw)

On Mar 21, 2018 05:40, "Steven D'Aprano" <steve@pearwood.info> wrote:

I don't want to change the behaviour of pow(), but we shouldn't dismiss
the possibility of some other numeric function wanting to treat values
N.0 and N the same. Let's say, an is\_prime(x) function that supports
floats as well as ints:

is\_prime(3.0) # True
is\_prime(3.00001) # False

For me this is an argument against is\_integer() rather than for it :-). is\_prime(float) should \*obviously\*\[1\] be a TypeError. Primality is only meaningfully defined over the domain of integers, and this is a case where operator.index is exactly what you want.

Of course it's just an example, and perhaps there are other, better examples. But it makes me nervous that this is the best example you could quickly come up with.

-n

\[1\] Warning: I am not Dutch.