def convert(value, type_):
    """Return the value converted to the type, or None if error.

    ``type_`` may be a Python type or any function taking one argument.
    """
    try:
        return type_(value)
    except Exception:
        return None
