[Python-Dev] os.path.diff(path1, path2) (original) (raw)
Nathan Bullock nathan_kent_bullock at yahoo.ca
Tue Sep 13 05:11:57 CEST 2005
- Previous message: [Python-Dev] PEP 3000 and iterators
- Next message: [Python-Dev] os.path.diff(path1, path2)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Just wondering if a function such as this has ever been considered? I find that I quite often want a function that will give me a relative path from path A to path B. I have created such a function, but it would be nice if it was in the standard library.
This function would take two paths: A and B and give the relation between them. Here are a few of examples.
os.path.diff("/A/C/D/", "/A/D/F/") ==> "../../D/F"
os.path.diff("/A/", "/A/B/C/") ==> "B/C"
os.path.diff("/A/B/C/", "/A/") ==> "../.."
I suppose it would also be nice if you could use path
- file. For example:
os.path.diff("/A/C/D/xyz.html", "/A/D/F/zlf.html") ==> "../../D/F/zlf.html"
I am not subscribed to the list so if anyone thinks this is useful please CC my email address.
I also want to say thank you to everyone who has made Python what it is today.
Nathan Bullock
Visit my website at http://www.nathanbullock.org
Find your next car at http://autos.yahoo.ca
- Previous message: [Python-Dev] PEP 3000 and iterators
- Next message: [Python-Dev] os.path.diff(path1, path2)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]