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

Guido van Rossum guido at python.org
Mon Mar 30 17:29:08 CEST 2009


On Mon, Mar 30, 2009 at 5:04 AM, Mart Sõmermaa <mrts.pydev at gmail.com> wrote:
> On Sat, Mar 28, 2009 at 5:26 AM, Guido van Rossum <guido at python.org> wrote:
>>
>> 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.
>
> So be it. I'll open a ticket and provide a patch, tests and documentation.
>
> For people concerned about ordering -- you can always use an odict for
> passing the kwargs:
>
> add_query_params('http://foo.com', **odict('a' = 1, 'b' = 2))

Alas, that doesn't work -- f(**X) copies X into a real dict.

But web apps that care about the order are crazy IMO.

> For people concerned about syntactically more restrictive rules than
> application/x-www-form-urlencoded allows -- pass in the kwargs via ordinary
> dict:
>
> add_query_params('http://foo.com', **{'|"-/': 1, 'öäü': 2}) # note that py2k
> allows UTF-8 in argument names anyway
>
> The latter is bad practice anyway.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list