[Python-Dev] os.path.diff(path1, path2)

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Sep 21 02:55:56 CEST 2005

Matthias Andreas Benkard wrote:

> But this begs the question: What is relpath good for, anyway?

[Assuming you mean "invites", "prompts", etc. the question...:-)]

A couple of use cases I've encountered:

* Creating symbolic links. I'm traversing a directory
   hierarchy, and building a parallel hierarchy somewhere
   else that contains symbolic links into the original
   one. I want the links to be relative, so that e.g. I
   can move my home directory without all my links breaking.

* In a recent project, I had occasion to store pathnames of
   picture files in a relational database. I wanted to store
   the pathnames relative to a user-chosen "Pictures"
   directory, so that it could be moved without having to
   update all the pathnames in the database.

Both of these happen to involve pathnames that exist on
the currrently available file system, but I can easily
imagine cases where that would not be so. E.g. I might
be generating pathames to go into a tar file that will
be unpacked in a different place or on another system.

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+

More information about the Python-Dev mailing list