[Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
Steven D'Aprano
steve at pearwood.info
Mon Apr 20 01:03:28 CEST 2009
On Mon, 20 Apr 2009 05:26:59 am Bill Janssen wrote:
> Mart Sõmermaa <mrts.pydev at gmail.com> wrote:
> > On Sun, Apr 19, 2009 at 2:06 AM, Nick Coghlan <ncoghlan at gmail.com>
wrote:
> > > That said, I'm starting to wonder if an even better option may be
> > > to just drop the kwargs support from the function and require
> > > people to always supply a parameters dictionary. That would
> > > simplify the signature to the quite straightforward:
> > >
> > > def add_query_params(url, params, allow_dups=True, sep='&')
>
> Or even better, stop trying to use a mapping, and just make the
> "params" value a list of (name, value) pairs. That way you can stop
> fiddling around with "allow_dups" and just get rid of it.
Surely it should support any mapping? That's what I do in my own code.
People will use regular dicts for convenience when they don't care
about order or duplicates, and (name,value) pairs, or an OrderedDict,
when they do.
I suppose you could force people to write params.items() if params is a
dict, but it seems wrong to force an order on input data when it
doesn't require one.
--
Steven D'Aprano
More information about the Python-Dev
mailing list