6 def relative (dir, r=os.getcwd ()):
7 dir = os.path.normpath (dir) + '/'
8 r = os.path.normpath (r) + '/'
9 prefix = len (os.path.commonprefix ((dir, r)))
10 if prefix == len (dir):
13 return '../' * (len (r[prefix:].split ('/')) - 1) + dir[prefix:]
16 if __name__ == '__main__':
17 print relative (sys.argv[1])