The Incomplete Works of Josh English

Writings and Ramblings about almost anything...

relPath.py

In creating my WebMenu program I found it necessary to put together this package. It has two functions, relPathTo and relPathFrom . The relPathTo function does all the work.

Download relpath.py here.

Download relpathtest.py here.

The relPathTo function takes two full URL‹s as parameters (“Here” and “There”) and returns a relative path. If the paths are on different servers, the complete path is returned. If the paths are on the same server but with different users the complete path is returned. Otherwise it returns a proper relative path.

relPathTo handles page fragments but ignores parameters in the URL.