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

Cameron Simpson cs at zip.com.au
Sun Apr 12 23:17:46 CEST 2009


On 12Apr2009 16:15, Mart S?mermaa <mrts.pydev at gmail.com> wrote:
| On Sun, Apr 12, 2009 at 3:23 PM, Jacob Holm <jh at improva.dk> wrote:
| > Hi Mart
| >    >>> add_query_params('http://example.com/a/b/c?a=b', b='d', foo='/bar')
| >>    'http://example.com/a/b/c?a=b&b=d&foo=%2Fbar <
| >> http://example.com/a/b/c?a=b&b=d&foo=%2Fbar>'
| >>
| >> Duplicates are discarded:
| >
| > Why discard duplicates?  They are valid and have a well-defined meaning.
| 
| The bad thing about reasoning about query strings is that there is no
| comprehensive documentation about their meaning. Both RFC 1738 and RFC 3986
| are rather vague in that matter. But I agree that duplicates actually have a
| meaning (an ordered list of identical values), so I'll remove the bits that
| prune them unless anyone opposes (which I doubt).

+1 from me, with the following suggestion: it's probably worth adding the
to doco that people working with dict-style query_string params should
probably go make a dict or OrderedDict and use:

  add_query_params(..., **the_dict)

just to make the other use case obvious.

An alternative would be to have add_ and append_ methods with set and
list behaviour. Feels a little like API bloat, though the convenience
function can be nice.

Cheers,
-- 
Cameron Simpson <cs at zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

The wonderous pulp and fibre of the brain had been substituted by brass and
iron; he had taught wheelwork to think. - Harry Wilmot Buxton 1832,
                referring to Charles Babbage and his difference engine.



More information about the Python-ideas mailing list