Eric V. Smith <e...@trueblade.com> added the comment:
One way I can think of doing this in a backward compatible way is to add keyword parameters to urlunparse, like: def urlunparse(components, *, username=None, password=None, hostname=None, port=None): Which would make your call: site_to_test = urllib.parse.urlunparse((scheme, host, page, '', '', ''), port=9097) I think that's a horrible interface, but it is backward compatible. A better interface would be have all 10 URL parameters passed in as keyword arguments, with reasonable defaults. If you want to keep this named "urlunparse", you'd need to say you can't pass in both "components" and any other named parameter (other than maybe the 4 parameters that are unnamed in ParseResult). Something like: def urlunparse(components=None, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None, *, username=None, password=None, hostname=None, port=None): Then error if components is set and any of scheme, netloc, path, params, query, or fragment is also set. We could bikeshed about which would be keyword-only, if any, all, or only some as I've shown here. Another option would be to leave urlunparse alone, and add a new function entirely, which wouldn't have to worry about backward compatibility. It might be worthwhile to raise this on python-ideas. ---------- nosy: +eric.smith _______________________________________ 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