I think you want urllib.basejoin().
>>> urllib.basejoin("http://www.example.com/test/page.html", "otherpage.html") 'http://www.example.com/test/otherpage.html'
pgpSOZBAEHiWi.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list