def force_int(num, default=None):
    """
    Force a value to an integer. If the value
    cannot be converted return the default value.
    """
    try:
        return int(num)
    except (ValueError, TypeError):
        return default
