def convert_to_type(value, value_type, default_value=None):
    """
    Try to convert 'value' to type
    :param value: The value to convert
    :param value_type: The type to convert to eg: int, float, bool
    :param default_value: The default returned value if the conversion fails
    :return:
    """

    try:
        return value_type(value)
    except ValueError:
        return default_value