Hi, > 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'm not sure whether something like this is generally non-trivial. Suppose you have the following directory structure: /home -> usr/home /usr /usr/home What does os.path.diff("/home/", "/usr/") yield? "../usr/", I would presume? But that's obviously wrong: >>> import os >>> os.stat("/home/../usr") Traceback (most recent call last): File "<stdin>", line 1, in ? OSError: [Errno 2] No such file or directory: '/home/../usr' I've not thought about this long enough to say if there's a trivial solution to this, though :) Bye, Matthias A. Benkard ________________________________________________________________________ Matthias Andreas Benkard, Anarchokommunist und Pythonprogrammierer Persönliche Website: http://www.mulk.de.vu/ Persönlicher Weblog: http://www.kompottkin.de.vu/ Flames bitte nach /dev/null schicken.
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com