Safely parse a string into an int.

    On error return the ``default`` value.

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

def safe_int(string, default=None):
    """
    Safely parse a string into an int.

    On error return the ``default`` value.

    :param string string: string value to be converted
    :param int default: default value to be used in case of failure
    :rtype: int
    """
    value = safe_float(string, default)
    if value is not None:
        value = int(value)
    return value