(self, *other)
return self._from_parsed_parts('', root if n == 1 else '',
                                       abs_parts[n:])
Return the relative path to another path identified by the passed
        arguments.  If the operation is not possible (because this is not
        a subpath of the other path), raise ValueError.
Return the relative path to another path identified by the passed
        arguments.  If the operation is not possible (because this is not
        a subpath of the other path), raise ValueError.
Return the relative path to another path identified by the passed arguments . If the operation is not possible ( because this is not a subpath of the other path ) raise ValueError .
def relative_to(self, *other):
        """Return the relative path to another path identified by the passed
        arguments.  If the operation is not possible (because this is not
        a subpath of the other path), raise ValueError.
        """
        # For the purpose of this method, drive and root are considered
        # separate parts, i.e.:
        #   Path('c:/').relative_to('c:')  gives Path('/')
        #   Path('c:/').relative_to('/')   raise ValueError
        if not other:
            raise TypeError("need at least one argument")
        parts = self._parts
        drv = self._drv
        root = self._root
        if root:
            abs_parts = [drv, root] + parts[1:]
        else:
            abs_parts = parts
        to_drv, to_root, to_parts = self._parse_args(other)
        if to_root:
            to_abs_parts = [to_drv, to_root] + to_parts[1:]
        else:
            to_abs_parts = to_parts
        n = len(to_abs_parts)
        cf = self._flavour.casefold_parts
        if (root or drv) if n == 0 else cf(abs_parts[:n]) != cf(to_abs_parts):
            formatted = self._format_parsed_parts(to_drv, to_root, to_parts)
            raise ValueError("{!r} is not in the subpath of {!r}"
                    " OR one path is relative and the other is absolute."
                             .format(str(self), str(formatted)))
        return self._from_parsed_parts('', root if n == 1 else '',
                                       abs_parts[n:])
def relative_to ( self , * other ) : # For the purpose of this method, drive and root are considered # separate parts, i.e.: #   Path('c:/').relative_to('c:')  gives Path('/') #   Path('c:/').relative_to('/')   raise ValueError if not other : raise TypeError ( "need at least one argument" ) parts = self . _parts drv = self . _drv root = self . _root if root : abs_parts = [ drv , root ] + parts [ 1 : ] else : abs_parts = parts to_drv , to_root , to_parts = self . _parse_args ( other ) if to_root : to_abs_parts = [ to_drv , to_root ] + to_parts [ 1 : ] else : to_abs_parts = to_parts n = len ( to_abs_parts ) cf = self . _flavour . casefold_parts if ( root or drv ) if n == 0 else cf ( abs_parts [ : n ] ) != cf ( to_abs_parts ) : formatted = self . _format_parsed_parts ( to_drv , to_root , to_parts ) raise ValueError ( "{!r} is not in the subpath of {!r}" " OR one path is relative and the other is absolute." . format ( str ( self ) , str ( formatted ) ) ) return self . _from_parsed_parts ( '' , root if n == 1 else '' , abs_parts [ n : ] )