[Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
Guido van Rossum
guido at python.org
Sat Mar 28 03:26:44 CET 2009
There's way too much bikeshedding in this thread (not picking on you
specifically). I think the originally proposed API is fine, except it
should *not* reject duplicates. To add duplicates you'd just call it
multiple times, e.g. add_query_params(add_query_params(url, a='x'),
a='y'). It's a pretty minor use case anyways.
--Guido
On Fri, Mar 27, 2009 at 7:28 PM, George Sakkis <george.sakkis at gmail.com> wrote:
> 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
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
More information about the Python-ideas
mailing list