Q:

why doesn't python return booleans

I have this small function that takes two integers a and b and checks if a is b raised to some exponent. This is the code.
def is_power(a,b):

    if not a%b==0:
        return a%b==0

    elif a/b==1:
       return a/b==1

    else:
        a = a/b
        is_power(a,b)

print is_power(,) 

The problem is that this always returns None no matter what I input.
But if I replace all returns with prints, then they give the correct result, i.e. True or False.
def is_power(a,b):

    if not a%b==0:
        print a%b==0

    elif a/b==1:
       print a/b==1

    else:
        a = a/b
        is_power(a,b)

is_power(,) 

Why does this happen? This is probably a noob question, but I still can't think it out.
Thanks

A:

You are ignoring the return value of the recursive call, add a return there:
else:
    a = a/b
    return is_power(a,b)

Without the return statement there, your function just ends and returns None instead. The return value of the recursive call is otherwise ignored.
With the return statement, your code works:
>>> def is_power(a,b):
...     if not a%b==0:
...         return a%b==0
...     elif a/b==1:
...        return a/b==1
...     else:
...         a = a/b
...         return is_power(a, b)
... 
>>> print is_power(10, 3)
False
>>> print is_power(8, 2)
True

A:

You forgot to return on the last else clause.

