def getSep(path, pattern='/\\'):
    """
    Get path separator or indicator.

    :param path: relative or absolute path (str).
    :param pattern: guess characters to compare path (str).
    :return: sep (str).

    .. note:: It is equivalent to os.path.sep but obtained from the given path and patterns.
    """
    i = len(path)
    while i and path[i - 1] not in pattern:
        i -= 1
    head, tail = path[:i], path[i:]  # now tail has no slashes
    # remove trailing slashes from head, unless it's all slashes
    head2 = head
    count = 0
    while head2 and head2[-1] in pattern:
        head2 = head2[:-1]
        count += 1
    character = head[len(head) - count:len(head)]  # get the slash character
    return character