[Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)

George Sakkis george.sakkis at gmail.com
Sat Mar 28 01:28:59 CET 2009


On Fri, Mar 27, 2009 at 7:36 PM, Terry Reedy <tjreedy at udel.edu> wrote:

> Joel Bender wrote:
>>>
>>> It's also possible that the order matters. I think an iterable of tuples
>>> (such as returned by dict.items(), but any iterable will do) would be an
>>> okay interface.
>>
>> Ordered dict then :-)
>
> But that, unlike iterable of tuples, would exclude repeated fields, as in
> Arnaud's example
>
>>Note that it's still not general enough as query fields can be repeated,
>> e.g.
>>http://foo.com/search/?q=spam&q=eggs

Repeated fields can be packed together in a tuple/list:

add_query_params('http://foo.com', dict(q=('spam', 'eggs')))

To which one might reply that this would exclude non-consecutive
repeated fields,e g. '?q=spam&foo=bar&q=eggs.

To which I would reply that for this 0.01% of cases that require this
(a) do it by hand as now or (b) use the same signature as dict() (plus
the host in the beginning):

add_query_params(host, mapping_or_iterable=None, **params)

George



More information about the Python-ideas mailing list