Finding the relative path of a file from a dir
Hi, 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? Thanks in advance, Suresh -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the relative path of a file from a dir
http://groups.google.com/group/comp.lang.python/browse_thread/thread/390d8d3e3ac8ef44/d8c74f96468c6a36?q=relative+pathrnum=1#d8c74f96468c6a36 -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the relative path of a file from a dir
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
Re: Finding the relative path of a file from a dir
Suresh Jeevanandam wrote: Hi, 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. '../..' Jason Orendorff's path module has a method for this (relpathto()). http://www.jorendorff.com/articles/python/path/index.html Kent -- http://mail.python.org/mailman/listinfo/python-list
Re: Finding the relative path of a file from a dir
pathutils has a function to do this (actually extracted from the path module). http://www.voidspace.org.uk/python/pathutils.html All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list