Use the math module's isfinite method to determine if a value is finite or not. If it is not a number, the function returns false.
isfinite
See below for an example:
math.isfinite(10) returns True