Eric V. Smith <e...@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 <rep...@bugs.python.org> <https://bugs.python.org/issue38408> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com