(segments, remove)
return ret
Removes the path segments of <remove> from the end of the path
    segments <segments>.

    Examples:
      # ('/a/b/c', 'b/c') -> '/a/'
      remove_path_segments(['','a','b','c'], ['b','c']) == ['','a','']
      # ('/a/b/c', '/b/c') -> '/a'
      remove_path_segments(['','a','b','c'], ['','b','c']) == ['','a']

    Returns: The list of all remaining path segments after the segments
    in <remove> have been removed from the end of <segments>. If no
    segments from <remove> were removed from <segments>, <segments> is
    returned unmodified.
Removes the path segments of <remove> from the end of the path
    segments <segments>.
Removes the path segments of <remove > from the end of the path segments <segments > .
def remove_path_segments(segments, remove):
    """
    Removes the path segments of <remove> from the end of the path
    segments <segments>.

    Examples:
      # ('/a/b/c', 'b/c') -> '/a/'
      remove_path_segments(['','a','b','c'], ['b','c']) == ['','a','']
      # ('/a/b/c', '/b/c') -> '/a'
      remove_path_segments(['','a','b','c'], ['','b','c']) == ['','a']

    Returns: The list of all remaining path segments after the segments
    in <remove> have been removed from the end of <segments>. If no
    segments from <remove> were removed from <segments>, <segments> is
    returned unmodified.
    """
    # [''] means a '/', which is properly represented by ['', ''].
    if segments == ['']:
        segments.append('')
    if remove == ['']:
        remove.append('')

    ret = None
    if remove == segments:
        ret = []
    elif len(remove) > len(segments):
        ret = segments
    else:
        toremove = list(remove)

        if len(remove) > 1 and remove[0] == '':
            toremove.pop(0)

        if toremove and toremove == segments[-1 * len(toremove):]:
            ret = segments[:len(segments) - len(toremove)]
            if remove[0] != '' and ret:
                ret.append('')
        else:
            ret = segments

    return ret
def remove_path_segments ( segments , remove ) : # [''] means a '/', which is properly represented by ['', '']. if segments == [ '' ] : segments . append ( '' ) if remove == [ '' ] : remove . append ( '' ) ret = None if remove == segments : ret = [ ] elif len ( remove ) > len ( segments ) : ret = segments else : toremove = list ( remove ) if len ( remove ) > 1 and remove [ 0 ] == '' : toremove . pop ( 0 ) if toremove and toremove == segments [ - 1 * len ( toremove ) : ] : ret = segments [ : len ( segments ) - len ( toremove ) ] if remove [ 0 ] != '' and ret : ret . append ( '' ) else : ret = segments return ret