Suresh Jeevanandam wrote: > a = '/home/suresh/doc/html/a1/' > b = '/home/suresh/doc/' > > I am looking for a standard function which will return the location of b > relative to a i.e. '../..' > > I have gone through the os and os.path modules, but could not find any > function of use. Should I write my own?
Don't write your own. This is yet another thing that Jason Orendorff's path.py module can do easily: >>> from path import path >>> b = path('/users/peter/') >>> a = path('/users/peter/synergy/tiki.txt') >>> a.relpathto(b) path(u'..\\..') -Peter -- http://mail.python.org/mailman/listinfo/python-list