Finding the relative path of a file from a dir

S

Suresh Jeevanandam

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
 
P

Peter Hansen

Suresh said:
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:
path(u'..\\..')

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top