def _relpath(path, start='.'):
 if (not path):
  raise ValueError('no path specified')
 startList = os.path.abspath(start).split(os.path.sep)
 pathList = os.path.abspath(path).split(os.path.sep)
 i = len(os.path.commonprefix([startList, pathList]))
 relList = ((['..'] * (len(startList) - i)) + pathList[i:])
 if (not relList):
  return path
 return os.path.join(*relList)

def _relpath ( path , start = '.' ) : if ( not path ) : raise ValueError ( 'no path specified' ) startList = os . path . abspath ( start ) . split ( os . path . sep ) pathList = os . path . abspath ( path ) . split ( os . path . sep ) i = len ( os . path . commonprefix ( [ startList , pathList ] ) ) relList = ( ( [ '..' ] * ( len ( startList ) - i ) ) + pathList [ i : ] ) if ( not relList ) : return path return os . path . join ( * relList )
this code is based on os .