

def set_query_parameter(url, param_name, param_value):
    "Given a URL, set or replace a query parameter and return the\n    modified URL. Stackoverflow: http://stackoverflow.com/a/12897375\n\n    >>> set_query_parameter('http://example.com?foo=bar&biz=baz', 'foo', 'stuff')\n    'http://example.com?foo=stuff&biz=baz'\n\n    "
    (scheme, netloc, path, query_string, fragment) = urlsplit(url)
    query_params = parse_qs(query_string)
    query_params[param_name] = [param_value]
    new_query_string = urlencode(query_params, doseq=True)
    return urlunsplit((scheme, netloc, path, new_query_string, fragment))

dataset/ETHPy150Open BuongiornoMIP/Reding/reding/tests/utils.py set_query_parameter/original