[issue38408] urlparse gives no method to build a url with a port
Eric V. Smith
report at bugs.python.org
Wed Oct 9 10:44:33 EDT 2019
Eric V. Smith <eric at trueblade.com> added the comment:
Yes, that does work:
>>> urllib.parse.urlunparse(("http", f"{host}:{port}", "/", "", "", ""))
'http://hostname:1234/'
The only problem is that your code now needs to look like
>>> port=None
>>> urllib.parse.urlunparse(("http", f"{host}{(':' + str(port)) if port else ''}", "/", "", "", ""))
'http://hostname/'
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38408>
_______________________________________
More information about the Python-bugs-list
mailing list