def cast_or_none(value, cast_function):
    """
    Cast a value to a desired type, or return None if the cast is not possible
    :param value: value
    :param cast_function: cast function like float, int or str
    :return: casted value or None
    """
    try:
        return cast_function(value)
    except (TypeError, ValueError):
        return None