>>> import urlparse
>>> urlparse.urljoin('http://stackoverflow.com/questions/ask',
... '/users/48465/jader-dias')
'http://stackoverflow.com/users/48465/jader-dias'
From the doc page of urlparse.urljoin:
urlparse.urljoin(base, url[,
allow_fragments])
Construct a full (“absolute”) URL by combining a “base URL” (base) with
another URL (url). Informally, this
uses components of the base URL, in
particular the addressing scheme, the
network location and (part of) the
path, to provide missing components in
the relative URL.
If url is an absolute URL (that is,
starting with // or scheme://), the
url‘s host name and/or scheme will be
present in the result.