def str2tuple(s, sep=',', converter=None, *, maxsplit=-1):
    """Convert a string to a tuple.

    If ``converter`` is given and not ``None``, it must be a callable that
    takes a string parameter and returns an object of the required type,
    or else a tuple with string elements will be returned.

    >>> str2tuple('1, 2, 3,4', converter=int)
    (1, 2, 3, 4)
    >>> str2tuple('on, off, no, true, YES')
    ('on', 'off', 'no', 'true', 'YES')
    >>> str2tuple('on, off, no, true, YES', converter=str2bool)
    (True, False, False, True, True)
    >>> str2tuple('a, b, , d')
    ('a', 'b', '', 'd')

    :param str s: the string
    :param str sep: the separator (whitespace around ``sep`` will be ignored)
    :param converter: the converter function
    :type converter: callable(str)
    :param int maxsplit: max. number of splits (-1 means no limit)
    :return: tuple with elements of the required type
    :rtype: tuple

    .. versionchanged:: 0.14.0 Add parameter ``maxsplit``
    """
    if s:
        f = converter or str
        return tuple(f(x.strip()) for x in s.split(sep, maxsplit))
    return ()