Message304637
It would be useful to document that urllib.parse.{Defrag,Split,Parse}Result are namedtuples, and make that API officially public if it was not otherwise.
These classes are implemented as namedtuples in Python 2 and 3, and I am not aware of a reason that that would need to change in the future.
In particular, the namedtuple _replace() method is very useful for modifying parts of a URL, a common use case.
u = urllib.parse.urlsplit(some_url)
u = u._replace(netloc=other_netloc)
urllib.parse.urlunsplit(u)
# Alternatives not depending on namedtuple API
parts = list(u)
parts[1] = other_netloc # Using a magic index
urllib.parse.urlunsplit(u)
u = urllib.parse.SplitResult( # Very ugly
scheme=u.scheme,
netloc=other_netloc,
path=u.path,
query=u.query,
fragment=u.fragment) |
|
Date |
User |
Action |
Args |
2017-10-19 18:54:33 | Allen Li | set | recipients:
+ Allen Li, docs@python |
2017-10-19 18:54:33 | Allen Li | set | messageid: <1508439273.05.0.213398074469.issue31822@psf.upfronthosting.co.za> |
2017-10-19 18:54:32 | Allen Li | link | issue31822 messages |
2017-10-19 18:54:32 | Allen Li | create | |
|