Number check for is_prime()



This is another piece of code to criiticize and improve.

from numbers import Number

def is_prime(number):
    def is_num():
        return isinstance(number, Number)
    def test_num():
        return int(number)
    return False if not is_num() else test_num()

At present it is only a skeleton to see what returns False. The objective is fairly clear.


Ahh is this an exercise for whoever passes by? Please delete my reply if that's the case.

Since is_num and test_num presumably both return booleans, they could be combined with just and/or instead of using a ternary expression.

Why the inner functions?


For scope, and for now. test_num is meant to contain the prime testing code.


because I could.. This is still foreign to me and I'm struggling to get a working object model in front of me. Do forgive my clumsiness. Thank you!