[Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7) (original) (raw)
Mart Sõmermaa mrts.pydev at gmail.com
Sat Apr 18 22:42:40 CEST 2009
- Previous message: [Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
- Next message: [Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sat, Apr 18, 2009 at 3:41 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
Yep - Guido has pointed out in a few different API design discussions that a boolean flag that is almost always set to a literal True or False is a good sign that there are two functions involved rather than just one. There are exceptions to that guideline (e.g. the reverse argument for sorted and list.sort), but they aren't common, and even when they do crop up, making them keyword-only arguments is strongly recommended.
As you yourself previously noted -- "it is often better to use *args for the two positional arguments - it avoids accidental name conflicts between the positional arguments and arbitrary keyword arguments" -- kwargs may cause name conflicts.
But I also agree, that the current proliferation of positional args is ugly.
add_query_params_no_dups() would be suboptimal though, as there are currently three different ways to handle the duplicates:
- allow duplicates everywhere (True),
- remove duplicate values for the same key (False),
- behave like dict.update -- remove duplicate keys, unless explicitly passed a list (None).
(See the documentation at http://github.com/mrts/qparams/blob/bf1b29ad46f9d848d5609de6de0bfac1200da310/qparams.py ).
Additionally, as proposed by Antoine Pitrou, removing keys could be implemented.
It feels awkward to start a PEP for such a marginal feature, but clearly a couple of enlightened design decisions are required.
- Previous message: [Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
- Next message: [Python-Dev] [Python-ideas] Proposed addtion to urllib.parse in 3.1 (and urlparse in 2.7)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]