Author eric.smith
Recipients Amir, James Allsopp, eric.smith
Date 2019-10-08.12:34:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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.
Date User Action Args
2019-10-08 12:34:38eric.smithsetrecipients: + eric.smith, Amir, James Allsopp
2019-10-08 12:34:38eric.smithsetmessageid: <>
2019-10-08 12:34:38eric.smithlinkissue38408 messages
2019-10-08 12:34:38eric.smithcreate