Re: modifying parts of a urlparse.SplitResult

2016-01-12 Thread Tim Chase
On 2016-01-12 13:46, Peter Otten wrote: > Tim Chase wrote: > > >>> u = urlparse.urlsplit(URL) > > >>> lst = list(u) # can't manipulate the tuple directly > > >>> lst[3] = "bar=baz" # 3 = query-string index > > >>> urlparse.urlunsplit(lst) > > 'http://foo/path1/path2/?bar=baz' > > > > It

Re: modifying parts of a urlparse.SplitResult

2016-01-12 Thread Peter Otten
Tim Chase wrote: > I can successfully parse my URLs. However, I'd like to modify a part > then reassemble them. However, like tuples, the parts appear to be > unmodifiable > > >>> URL = 'http://foo/path1/path2/?fragment=foo' > >>> import urlparse > >>> u = urlparse.urlparse(URL) > >>> u

modifying parts of a urlparse.SplitResult

2016-01-12 Thread Tim Chase
I can successfully parse my URLs. However, I'd like to modify a part then reassemble them. However, like tuples, the parts appear to be unmodifiable >>> URL = 'http://foo/path1/path2/?fragment=foo' >>> import urlparse >>> u = urlparse.urlparse(URL) >>> u ParseResult(scheme='http', ne