
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@gmail.com> wrote:
On Fri, Mar 27, 2009 at 7:36 PM, Terry Reedy <tjreedy@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@python.org http://mail.python.org/mailman/listinfo/python-ideas
-- --Guido van Rossum (home page: http://www.python.org/~guido/)