Safely parse a string into a float.

    On error return the ``default`` value.

    :param string string: string value to be converted
    :param float default: default value to be used in case of failure
    :rtype: float

def safe_float(string, default=None):
    """
    Safely parse a string into a float.

    On error return the ``default`` value.

    :param string string: string value to be converted
    :param float default: default value to be used in case of failure
    :rtype: float
    """
    value = default
    try:
        value = float(string)
    except TypeError:
        pass
    except ValueError:
        pass
    return value