import math


def isfinite(n):
    """Return True if x is neither an infinity nor a NaN, and False otherwise.
    (Note that 0.0 is considered finite.)

    Backported from python 3
    """

    return not (math.isinf(n) or math.isnan(n))