[python] Checking whether a variable is an integer or not

Consider the case x = n**(1.0/m), where n=10**5, m=5. In Python, x will be 10.000000000000002, which is only not integer because of floating point arithmetic operations.

So I'd check

if str(float(x)).endswith('.0'): print "It's an integer."

I've tested it with this code:

for a in range(2,100):
    for b in range(2,100):
        x = (a**b)**(1.0/b)
        print a,b, x, str(float(x)).endswith('.0')

It outputs True for all a and b.