(path, start=curdir)
return join(*rel_list)
Return a relative version of a path
Return a relative version of a path
Return a relative version of a path
def relpath(path, start=curdir):
    """Return a relative version of a path"""

    if not path:
        raise ValueError("no path specified")

    start_is_unc, start_prefix, start_list = _abspath_split(start)
    path_is_unc, path_prefix, path_list = _abspath_split(path)

    if path_is_unc ^ start_is_unc:
        raise ValueError("Cannot mix UNC and non-UNC paths (%s and %s)"
                                                            % (path, start))
    if path_prefix.lower() != start_prefix.lower():
        if path_is_unc:
            raise ValueError("path is on UNC root %s, start on UNC root %s"
                                                % (path_prefix, start_prefix))
        else:
            raise ValueError("path is on drive %s, start on drive %s"
                                                % (path_prefix, start_prefix))
    # Work out how much of the filepath is shared by start and path.
    i = 0
    for e1, e2 in zip(start_list, path_list):
        if e1.lower() != e2.lower():
            break
        i += 1

    rel_list = [pardir] * (len(start_list)-i) + path_list[i:]
    if not rel_list:
        return curdir
    return join(*rel_list)
def relpath ( path , start = curdir ) : if not path : raise ValueError ( "no path specified" ) start_is_unc , start_prefix , start_list = _abspath_split ( start ) path_is_unc , path_prefix , path_list = _abspath_split ( path ) if path_is_unc ^ start_is_unc : raise ValueError ( "Cannot mix UNC and non-UNC paths (%s and %s)" % ( path , start ) ) if path_prefix . lower ( ) != start_prefix . lower ( ) : if path_is_unc : raise ValueError ( "path is on UNC root %s, start on UNC root %s" % ( path_prefix , start_prefix ) ) else : raise ValueError ( "path is on drive %s, start on drive %s" % ( path_prefix , start_prefix ) ) # Work out how much of the filepath is shared by start and path. i = 0 for e1 , e2 in zip ( start_list , path_list ) : if e1 . lower ( ) != e2 . lower ( ) : break i += 1 rel_list = [ pardir ] * ( len ( start_list ) - i ) + path_list [ i : ] if not rel_list : return curdir return join ( * rel_list )