def as_float_default(s, default=0):
    """Cast a string to float or return a default value instead of throwing an
    error on invalid argument.
    """
    try:
        return float(s)
    except ValueError:
        return default