I think the right way to do this is exactly so.
As using _replace private methods or variables are not suggested.
from urlparse import urlparse, urlunparse res = urlparse('http://www.goog.com:80/this/is/path/;param=paramval?q=val&foo=bar#hash') l_res = list(res)
source share